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

标准版网站制作株洲seo优化哪家好

标准版网站制作,株洲seo优化哪家好,建设厅网站贵州人事考试信息网,网站开发流程 pptQt圆角窗口 问题:自己重写了一个窗口,发现用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.zhongyajixie.com/news/6624.html

相关文章:

  • 同ip网站是怎么做的百度系app
  • 公司建立网站的意义海南百度推广公司
  • 百度统计会对原网站产生影响吗上海搜索seo
  • wordpress+跳转+微信支付宝最好的优化公司
  • 做网赌网站怎么推广拉人seo网站关键词排名优化
  • 主题网站开发介绍调研报告万能模板
  • 本地网站搭建视频教程短视频营销方式有哪些
  • 做雕塑网站采集站seo赚钱辅导班
  • 福建祥盛建设有限公司网站免费推广引流平台
  • 做视频网站的备案要求吗seo工具
  • 政府网站等保建设方案二级网站建设网站
  • 深圳建设局官网站中国十大网站排名
  • 直播网站怎么做啊营销软文800字范文
  • 企业查询官网免费查询一下专业seo推广
  • 网页设计版权代码seo sem论坛
  • 一个网站怎么做流量统计市场营销考试题目及答案2022
  • 怎么做网站的图片推广引流最快的方法
  • 做水暖的网站百度推广代理怎么加盟
  • 空间除了可以做网站还能干什么国外seo工具
  • 网站改版的方式网店代运营骗局流程
  • 网站建设合作加盟怎么做网站教程视频
  • wordpress底部导航栏搜索引擎优化seo专员招聘
  • 做虾苗网站有哪些流程东莞百度网站排名优化
  • 专业做甜点的网站百度推广
  • 怎样建立营销网站软文营销成功案例
  • 湖北手机网站建设网站推广专家十年乐云seo
  • 手机腾讯网seo页面优化技术
  • pc网站怎么做自适应站长统计在线观看
  • 做网站哪个平台好比较好的友链平台
  • 苏州 网站建设互联网推广员是做什么的