Important: Please read the Qt Code of Conduct -

QCheckBox style is different in Qt Creator using same stylesheet.

  • I'm using the same stylesheet when running my tool within Qt Creator but the QCheckBox style appears different.
    On the left is the style outside of Qt Creator; the right shows the default stype when the tool is started within Qt Creator.
    I like the style on the right and would like to keep it, but I can't make it happen.
    I would like the QCheckBoxes to have the same background as the frame they are in, so the QSS looks like this:

    /* All checkboxes in frame */
    #selectAlertsTypeFrame QCheckBox {
    background-color: lightblue;

    Is there a way I can make the QCheckBoxes have the same white background as when the tool is started within Qt Creator?

  • Lifetime Qt Champion

    This looks like the underlying style is different - left looks like windows style, right fusion

  • When you run the program "without" Qt creator, do you mean you deployed the dlls with the exe and run the exe directly?
    Looks like you didn't copy the styles plugin folder with qwindowsvistastyle.dll, so it is using xp style.

  • @Christian-Ehrlicher Both are running on the same machine, which is Windows 10 vs2019-64

  • @Bonnie Correct, ran from the command line in a different location.

    OMG, that was it....I didn't have the styles library.
    We use the opensource version and build it on a bunch of platforms, have been for a number of years, and we have never copied over the qwindowsvistastyle.dll library for windows.

    Do you know if there is a way I can just set that QCheckBox style using my QSS stylesheet?
    I would like it to look that way on Mac and Linux too, I just want the white background within the square. :)

  • @knightspace Use a QStyle: a.setStyle("fusion"); or a.setStyle("windows");

  • @eyllanesc Thanks, I'll give it a go.

  • Here it's close.

    Still can't get the background of the actual checkbox square box to be white, unless I use the qwindowsvistastyle.dll library...which is don't really want to do since I want it the same on all platforms.

    P.S. I'm watching my own post now, so I should get notified of replies.

  • @knightspace

    1. If you want the whole ui same on all platforms, not only the checkbox, then you should set the style to the application, not to the checkbox, as @eyllanesc posted (a is the QApplication in main.cpp)
    2. If you are using fusion style as the application style, then you don't need to set the checkbox's background color in qss, it should be just like what you want.(Unless it would inherit the background color from some parent widget, in that case you should modify the parent qss to make it not apply to the checkboxes.)

  • @Bonnie Thanks, but I'd like the style the stay as it is on the platforms, I really just want the little checkbox square to be white....picky right! :)

Log in to reply