备案 控制台
学习
实践
活动
专区
工具
TVP
写文章
4 0

海报分享

QSS样式表圆角

圆角

  • border-radius 属性。
  • 例子:
QPushButton *btn = new QPushButton(this);
btn->setStyleSheet(R"(
                   QPushButton
                       width: 100px;
                       height: 60px;
                       border-radius: 8px;
                       background-color: #008cba;
btn->show();

指定左上角圆角

  • border-top-left-radius 属性。
  • 例子:
QPushButton *btn = new QPushButton(this);
btn->setStyleSheet(R"(
                   QPushButton
                       width: 100px;
                       height: 60px;
                       border-top-left-radius: 8px;
                       background-color: #008cba;
btn->show();

指定右上角圆角

  • border-top-right-radius 属性。
  • 例子:
QPushButton *btn = new QPushButton(this);
btn->setStyleSheet(R"(
                   QPushButton
                       width: 100px;
                       height: 60px;
                       border-top-right-radius: 8px;
                       background-color: #008cba;
btn->show();

指定左下角圆角

  • border-bottom-left-radius 属性。
  • 例子:
QPushButton *btn = new QPushButton(this);
btn->setStyleSheet(R"(
                   QPushButton
                       width: 100px;
                       height: 60px;
                       border-bottom-left-radius: 8px;
                       background-color: #008cba;
btn->show();

指定右下角圆角

  • border-bottom-right-radius 属性。
  • 例子:
QPushButton *btn = new QPushButton(this);
btn->setStyleSheet(R"(
                   QPushButton
                       width: 100px;
                       height: 60px;
                       border-bottom-right-radius: 8px;
                       background-color: #008cba;
btn->show();

关于更多

  • 除了样式表圆角还可以设置某个边框的颜色、宽度。如:
/* 设置边框样式风格为实线 */
border-style: solid;
/* 设置顶部边框宽度为5px */
border-top-width: 5px; 
/* 设置顶部边框颜色为红色 */
border-top-color: red;
文章分享自微信公众号:
Qt君

本文参与 腾讯云自媒体分享计划 ,欢迎热爱写作的你一起参与!

原始发表时间: 2020-06-29
如有侵权,请联系 [email protected] 删除。