I'm unable to change the color of Qcheckbox
in QT, can somebody help me with code to change color of check box text label.
I have tried Qpalette
.. And im using QT4.7.4 version..
相关问题
- Sorting 3 numbers without branching [closed]
- QML: Cannot read property 'xxx' of undefin
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
I ran into this problem using various versions of Qt5 (5.2, 5.4). To do it with style sheets I had to use the Pseudo-States properties: http://doc.qt.io/qt-4.8/stylesheet-reference.html#list-of-pseudo-states
Example:
Setting both states changed the colors for me. It seems there are some oddities like this in the stylesheet and palette system so keep your eyes out for them and try a few different things (i.e. selectors, pseudo-states, etc.)
Looks like for some widgets you have to force using non-system "widget-engine". For checkbox it can be done by setting borders to none. So checkbox's style looks like:
Similar behavior is required by other widgets. Some style-properties do not disable native look. For example QPushButton (http://doc.qt.io/qt-4.8/stylesheet-reference.html)
You could use stylesheets:
For more details check the style sheets in Qt Reference and the stylesheets documentation
This works for me: