样式表示例显示了如何使用样式表。
样式表示例显示了如何使用Qt样式表设置窗口小部件的样式。您可以通过选择"File" >"Edit Style"来打开样式编辑器,以选择现有样式表或设计自己的样式并加载它。
样式表示例包含以下两个类:
MainWindow继承QWidget,并且是在中定义的应用程序主窗口mainwindow.ui。的样式MainWindow可以用修改StyleSheetEditor。
StyleSheetEditor使你可以打开样式表编辑器,在其中可以加载现有样式表。也可以定义一个新的样式表并加载它。其布局在中定义stylesheeteditor.ui。
void StyleSheetEditor::on_styleCombo_activated(const QString &styleName)
void StyleSheetEditor::on_styleSheetCombo_activated(const QString &sheetName)
void StyleSheetEditor::on_styleTextEdit_textChanged()
void StyleSheetEditor::on_applyButton_clicked()
void StyleSheetEditor::loadStyleSheet(const QString &sheetName)
C:\Qt\{你的Qt版本}\Examples\{你的Qt版本}\widgets\widgets\stylesheet
https://doc.qt.io/qt-5/qtwidgets-widgets-stylesheet-example.html