QCheckBox style is different in Qt Creator using same stylesheet.
-
wrote on 8 Dec 2020, 17:37 last edited by
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?
-
This looks like the underlying style is different - left looks like windows style, right fusion
-
wrote on 9 Dec 2020, 01:55 last edited by Bonnie 12 Sept 2020, 02:20
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 thestyles
plugin folder with qwindowsvistastyle.dll, so it is using xp style. -
This looks like the underlying style is different - left looks like windows style, right fusion
wrote on 14 Dec 2020, 17:06 last edited by@Christian-Ehrlicher Both are running on the same machine, which is Windows 10 vs2019-64
-
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 thestyles
plugin folder with qwindowsvistastyle.dll, so it is using xp style.wrote on 14 Dec 2020, 17:20 last edited by@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. :) -
@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. :)wrote on 14 Dec 2020, 17:23 last edited by eyllanesc@knightspace Use a QStyle:
a.setStyle("fusion");
ora.setStyle("windows");
-
@knightspace Use a QStyle:
a.setStyle("fusion");
ora.setStyle("windows");
wrote on 14 Dec 2020, 17:43 last edited by@eyllanesc Thanks, I'll give it a go.
-
wrote on 14 Dec 2020, 20:40 last edited by
Here it is....it's close.
ui->showNotesCheckBox->setStyle(QStyleFactory::create("Fusion"));
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.
-
Here it is....it's close.
ui->showNotesCheckBox->setStyle(QStyleFactory::create("Fusion"));
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.
wrote on 15 Dec 2020, 02:14 last edited by Bonnie- 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) - 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.)
- 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 (
-
- 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) - 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.)
wrote on 16 Dec 2020, 10:21 last edited by@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! :)
- 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 (
1/10