如何为应用程序中的某些按钮重置QApplication::styleSheet?
How to reset QApplication::styleSheet for certain buttons in application?
在我的main((函数中,我在应用程序的所有按钮上设置样式表。
qApp->setStyleSheet("QPushButton {"
" border: 1px solid #8f8f91;"
" border-radius: 4px;"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);"
" padding: 3px;"
" }");
但是现在我需要重置某些按钮的样式。我已经尝试过button->setStyleSheet("")
,但它不起作用。那么,该怎么做呢?
你不能。
你可以做的是相反的,即为某些按钮设置样式表,如下所示:
qApp->setStyleSheet("QPushButton[specialButton="true"] {"
" border: 1px solid #8f8f91;"
" border-radius: 4px;"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);"
" padding: 3px;"
"}");
然后:
button->setProperty("specialButton", true);
这样,只有将 specialButton 设置为 true
的按钮才会具有自定义外观,其他按钮看起来正常。
相关文章:
- 问:如何使用C++中的按钮从窗口打开窗口
- 如何将点击的信号和插槽添加到qt中的自定义按钮中
- QML按钮点击功能执行顺序
- 当用户超过按钮点击限制时报告
- 函数计算用户按下按钮的频率
- 热键/按钮,根据需要进行编译,但不运行(在F5和Ctrl+Shift+B之间)
- FLTK:按下哪个按钮 - 将数字传递给按钮的回调 (lambda)
- 如何通过按下第三个窗口中的按钮,将QString从一个窗口获取到另一个窗口
- 垂直方向的 Gtk3+ 旋转按钮 (c/c++)
- Qt自定义QPush按钮未显示在布局上
- SDL 操纵杆按钮按下/C++
- 如何使用按钮更新GTK3图像以使用C++从相机捕获图片
- Qt中来自不同功能的按钮引用
- WinAPI 在单击第一个对话框上的按钮控件并销毁第一个对话框后创建第二个对话框
- ImGui 在单击按钮后冻结
- WinAPI 无法创建按钮
- 按钮悬停在 QT 中垂直布局的选项卡小部件中不起作用
- 如何使用connect将qml按钮与同一类的cpp函数连接起来
- 如何为应用程序中的某些按钮重置QApplication::styleSheet?
- 使用Qt设计器的Qt按钮事件不起作用:"No such slot QApplication"