向Qt样式表添加特定性时丢失样式
Losing style when adding specificity to a Qt stylesheet
这是我的代码:
const QString STYLE_SHEET = "background-color: rgba(x,x,x,y);"
"border: 1px solid gray;"
"border-radius: 0px;"
"border-top: 1px solid red;"
"border-bottom: 1px solid blue;"
"border-radius: 0px;";
SS稍后应用于代码中,如下所示:
QWidget * myWidget;
myWidget = new QWidget(parent);
myWidget.setObjectName("myWidgetName");
myWidget.setStyleSheet(STYLE_SHEET);
它像冠军一样工作,只是边界渗入了子QFrame。如果我通过将STYLE_SHEET与以下内容括起来来为其添加特异性:
const QString QWidget#myWidgetName { }
STYLE_SHEET不再适用。它解决了子QFrame的流血问题,但我的QWidget失去了它的风格。没有风格的QWidget有什么用?
const QString STYLE_SHEET = "QWidget#myWidgetName {n"
" background-color: rgba(x,x,x,y);n"
" border: 1px solid gray;n"
" border-radius: 0px;n"
" border-top: 1px solid red;n"
" border-bottom: 1px solid blue;n"
" border-radius: 0px;n"
"}n";
相关文章:
- 更改"child's parent's style sheet"时如何将孩子的样式表重置为 Qt 默认样式表?
- QT 样式表主题,适用于使用属性选择器的整个应用程序
- Qt自定义小部件外观在设置样式表后没有变化
- Qt创建一个左箭头样式的按钮
- 无法增加 QToolButton 的大小(按钮样式设置为 Qt::ToolButtonTextBesideIcon)
- 无法在 qt 中为 QWidget 中的派生类设置样式表
- QT设置了所有对象以外的所有对象样式
- 如何在QT中设置样式表以选择假发背景的随机图像
- 如何在Qt样式表中使用嵌入字体
- QT 5.9.2 --> 5.10.0 应用程序样式丢失?
- Qt如何选择默认样式?
- 无法将样式添加到QT Tab小部件中的选项卡(bar)和Tab(窗格)
- Qt样式表和"一个参数"问题
- QAbstractListModel 和 Qt 样式表
- Qt样式表和QML有什么区别
- Qt样式表的用途以及它们的工作原理
- QT Designer-设置样式表 - 现在进行硬编码 - 想要以编程方式设置
- 如何在Qt应用程序中使用样式表更改QPush按钮图标大小
- c++ QT 默认样式太亮
- QTreeView的Qt样式表