Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QCheckBox style is different in Qt Creator using same stylesheet.
Forum Updated to NodeBB v4.3 + New Features

QCheckBox style is different in Qt Creator using same stylesheet.

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    knightspace
    wrote on last edited by
    #1

    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.
    ecfaca39-57a8-4a8c-95de-a98fa0a4dda2-image.png
    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?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      K 1 Reply Last reply
      2
      • B Offline
        B Offline
        Bonnie
        wrote on last edited by Bonnie
        #3

        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.

        K 1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher

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

          K Offline
          K Offline
          knightspace
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • B Bonnie

            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.

            K Offline
            K Offline
            knightspace
            wrote on last edited by
            #5

            @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. :)

            eyllanescE 1 Reply Last reply
            0
            • K knightspace

              @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. :)

              eyllanescE Offline
              eyllanescE Offline
              eyllanesc
              wrote on last edited by eyllanesc
              #6

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

              If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

              K 1 Reply Last reply
              1
              • eyllanescE eyllanesc

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

                K Offline
                K Offline
                knightspace
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  knightspace
                  wrote on last edited by
                  #8

                  Here it is....it's close.
                  ui->showNotesCheckBox->setStyle(QStyleFactory::create("Fusion"));
                  0ba99369-5b2a-4f01-a453-7a7360ec9417-image.png

                  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.

                  B 1 Reply Last reply
                  0
                  • K knightspace

                    Here it is....it's close.
                    ui->showNotesCheckBox->setStyle(QStyleFactory::create("Fusion"));
                    0ba99369-5b2a-4f01-a453-7a7360ec9417-image.png

                    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.

                    B Offline
                    B Offline
                    Bonnie
                    wrote on last edited by Bonnie
                    #9

                    @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.)
                    K 1 Reply Last reply
                    1
                    • B Bonnie

                      @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.)
                      K Offline
                      K Offline
                      knightspace
                      wrote on last edited by
                      #10

                      @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! :)

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved