当前位置: 首页 > news >正文

怎么做邮箱网站免费优化网站

怎么做邮箱网站,免费优化网站,蔚县网站建设wl17581,南岳政府门户网Qt圆角窗口 问题:自己重写了一个窗口,发现用qss设置圆角了,但是都不生效,不过子窗口圆角都生效了。 无边框移动窗口 bool eventFilter(QObject *watched, QEvent *evt) {static QPoint mousePoint;static bool mousePressed f…

Qt圆角窗口

问题:自己重写了一个窗口,发现用qss设置圆角了,但是都不生效,不过子窗口圆角都生效了。

无边框移动窗口

bool eventFilter(QObject *watched, QEvent *evt) {static QPoint mousePoint;static bool mousePressed = false;QMouseEvent *event = static_cast<QMouseEvent *>(evt);if (event->type() == QEvent::MouseButtonPress) {if (event->button() == Qt::LeftButton) {mousePressed = true;mousePoint = event->globalPos() - this->pos();return true;} else {return true;}} else if (event->type() == QEvent::MouseButtonRelease) {mousePressed = false;return true;} else if (event->type() == QEvent::MouseMove) {if (mousePressed && (event->buttons() && Qt::LeftButton)) {this->move(event->globalPos() - mousePoint);return true;}}return QWidget::eventFilter(watched, event);
}

1.当前窗口背景隐藏,使用子窗口圆角

红色背景为原来的窗口,里面的子窗口可以看到有圆角窗口了,隐藏掉就行setAttribute(Qt::WA_TranslucentBackground);
在这里插入图片描述
实现效果:
窗口还是存在的,只是透明了
在这里插入图片描述
代码:

void StyleSheetWidget::setRoundedRectangle1()
{setWindowFlags(Qt::FramelessWindowHint);setAttribute(Qt::WA_TranslucentBackground);//隐藏背景this->resize(200, 200);QFrame* title = new QFrame;QWidget* left = new QWidget;QWidget* mid = new QWidget;QWidget* right = new QWidget;// 布局QVBoxLayout *layoutMain = new QVBoxLayout;layoutMain->setContentsMargins(10, 10, 10, 10);QVBoxLayout *midLayout = new QVBoxLayout;midLayout->setContentsMargins(0,0,0,0);QWidget* midWid = new QWidget;midWid->setLayout(midLayout);layoutMain->addWidget(midWid);QHBoxLayout *hLayout_1 = new QHBoxLayout;hLayout_1->addWidget(left);hLayout_1->addWidget(mid);hLayout_1->addWidget(right);midLayout->addWidget(title);midLayout->addLayout(hLayout_1);title->setStyleSheet("background-color:green;border-bottom:3px solid black;");left->setStyleSheet("background-color:green;");mid->setStyleSheet("background-color:yellow;");right->setStyleSheet("background-color:blue;color:white");QLabel* label = new QLabel();label->setText("你好啊");QFormLayout* formLayout = new QFormLayout;formLayout->addRow(label);formLayout->addRow(new QLabel("你真的好啊,白云"));right->setLayout(formLayout);this->setLayout(layoutMain);this->setStyleSheet("border-radius: 8px;background-color:red;border: 1px solid #d9d9d9;");
}

2.使用paintEvent()绘制圆角

注意:使用paintEvent绘制圆角时候,布局之间要留一点距离,不然上层的绘制会把下面绘制的圆角给遮住了。如:

layoutMain->setContentsMargins(10,10,10,10);

设置布局间距离为10的效果:
在这里插入图片描述
设置为0效果:

    QVBoxLayout *layoutMain = new QVBoxLayout;layoutMain->setContentsMargins(0,0,0,0);

在这里插入图片描述
代码:

void StyleSheetWidget::paintEvent(QPaintEvent *event)
{QPainter painter(this);painter.setRenderHint(QPainter::Antialiasing);painter.setBrush(QColor(255,255,255));      //背景颜色//painter.setPen(Qt::red);//Qt::transparent); //边框颜色QPen pen;pen.setColor(Qt::red);pen.setWidth(3);painter.setPen(pen);QRect rect = this->rect();rect.setWidth(rect.width());rect.setHeight(rect.height());painter.drawRoundedRect(rect, 15, 15);QWidget::paintEvent(event);
}
http://www.hkea.cn/news/832875/

相关文章:

  • 郑州网站制作天强科技seo百度发包工具
  • 江阴市住房与建设局网站seo工资多少
  • wordpress image.php南宁百度首页优化
  • 谢家华做网站百度指数与百度搜索量
  • wordpress 安装 ubuntu整站优化代理
  • 做公司网站协议书模板下载百度竞价推广公司
  • 福田蒙派克6座二手值多少钱重庆seo点击工具
  • 有了域名 怎么做网站外贸网站推广方法之一
  • 审美网站长春网站建设路
  • 网站 管理系统域名查询注册信息查询
  • 专业网站设计发展前景推广网站软文
  • 怎么建设seo自己网站网站优化推广教程
  • 最新app开发软件石家庄网站建设seo公司
  • 江苏自助建站系统哪家好推广网站要注意什么
  • 唐河做网站关键字搜索引擎
  • 松江专业做网站公司seo视频教程百度云
  • 淄博品质网站建设竞价推广怎么样
  • 搜狗站群系统资源网站优化排名优化
  • 建设一个网站哪家好网站推广优化的原因
  • 做网站的上海公司有哪些情感链接
  • 梧州做网站建设数字营销公司
  • 加强新闻网站建设建议seo高手培训
  • 安丘网站建设制作怎样制作网页设计
  • 食品网站建设优化案例热门职业培训班
  • 龙华新区做网站大地seo视频
  • 网站彩票投注员做啥的真正免费的网站建站平台运营
  • wordpress 中文注册鸡西seo
  • 佛山企业如何建网站seo的内容怎么优化
  • 在什么网站上做自媒体windows优化大师是自带的吗
  • 装修公司的网站怎么做第三方营销平台有哪些