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. Colour differences in a group box on Windows
Forum Updated to NodeBB v4.3 + New Features

Colour differences in a group box on Windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 567 Views 2 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    I set the background colour of some group boxes to "light cyan" or "dark cyan" depending on the active Windows theme (light/dark).

    However the colour displayed varies:

    9e64ee47-6d2e-45de-8525-7128e423b469-image.png

    Which doesn't seem quite right ...

    Am I doing something wrong or is it Qt (6.5.1).

    Christian EhrlicherC 1 Reply Last reply
    0
    • PerdrixP Perdrix

      I set the background colour of some group boxes to "light cyan" or "dark cyan" depending on the active Windows theme (light/dark).

      However the colour displayed varies:

      9e64ee47-6d2e-45de-8525-7128e423b469-image.png

      Which doesn't seem quite right ...

      Am I doing something wrong or is it Qt (6.5.1).

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      'Settings...' is a QLabel, not a QGroupBox.

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

      PerdrixP 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        'Settings...' is a QLabel, not a QGroupBox.

        PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by Perdrix
        #3

        @Christian-Ehrlicher And it should inherit the background colour from the Groupbox (shouldn't it)?

        Christian EhrlicherC 1 Reply Last reply
        0
        • PerdrixP Perdrix

          @Christian-Ehrlicher And it should inherit the background colour from the Groupbox (shouldn't it)?

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Perdrix said in Colour differences in a group box on Windows:

          And it should inherit the background colour from the Groupbox (shouldn't it)?

          I don't know - you did not show any code on what you're doing.

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

          PerdrixP 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            @Perdrix said in Colour differences in a group box on Windows:

            And it should inherit the background colour from the Groupbox (shouldn't it)?

            I don't know - you did not show any code on what you're doing.

            PerdrixP Offline
            PerdrixP Offline
            Perdrix
            wrote on last edited by Perdrix
            #5

            @Christian-Ehrlicher Sorry here's my code that sets the colour for the group box:

            ui->options->setStyleSheet(QString("background-color: %1").arg(activeGroupColourName));

            the variable activeGroupColourName will be either "light-cyan" or "dark-cyan" depending on the active Windows theme.

            AFAIK the style background colour should propagate down from the group box to the contained QLabels?

            D.

            PerdrixP 1 Reply Last reply
            0
            • PerdrixP Perdrix

              @Christian-Ehrlicher Sorry here's my code that sets the colour for the group box:

              ui->options->setStyleSheet(QString("background-color: %1").arg(activeGroupColourName));

              the variable activeGroupColourName will be either "light-cyan" or "dark-cyan" depending on the active Windows theme.

              AFAIK the style background colour should propagate down from the group box to the contained QLabels?

              D.

              PerdrixP Offline
              PerdrixP Offline
              Perdrix
              wrote on last edited by
              #6

              Has anyone got some thoughts on this issue?

              Thanks, D.

              Christian EhrlicherC 1 Reply Last reply
              0
              • PerdrixP Perdrix

                Has anyone got some thoughts on this issue?

                Thanks, D.

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by Christian Ehrlicher
                #7

                You should be long enough here to know that we need a minimal, compilable example to reproduce the problem.
                Works fine for me on windows with Qt6.7:

                int main(int argc, char* argv[])
                {
                    QApplication app(argc, argv);
                    QWidget w;
                    w.setStyleSheet("background-color: red");
                    QHBoxLayout* lay = new QHBoxLayout(&w);
                    QGroupBox* groupBox = new QGroupBox("GroupBox");
                    QVBoxLayout* vbox = new QVBoxLayout(groupBox);
                    vbox->addWidget(new QLabel("Label 1"));
                    vbox->addWidget(new QLabel("Label 2"));
                    vbox->addWidget(new QLabel("Label 3"));
                    lay->addWidget(groupBox);
                    w.show();
                    return app.exec();
                }
                

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

                PerdrixP 1 Reply Last reply
                1
                • Christian EhrlicherC Christian Ehrlicher

                  You should be long enough here to know that we need a minimal, compilable example to reproduce the problem.
                  Works fine for me on windows with Qt6.7:

                  int main(int argc, char* argv[])
                  {
                      QApplication app(argc, argv);
                      QWidget w;
                      w.setStyleSheet("background-color: red");
                      QHBoxLayout* lay = new QHBoxLayout(&w);
                      QGroupBox* groupBox = new QGroupBox("GroupBox");
                      QVBoxLayout* vbox = new QVBoxLayout(groupBox);
                      vbox->addWidget(new QLabel("Label 1"));
                      vbox->addWidget(new QLabel("Label 2"));
                      vbox->addWidget(new QLabel("Label 3"));
                      lay->addWidget(groupBox);
                      w.show();
                      return app.exec();
                  }
                  
                  PerdrixP Offline
                  PerdrixP Offline
                  Perdrix
                  wrote on last edited by
                  #8

                  @Christian-Ehrlicher Yes, but if I knew how to create the problem, I'd probably know how to fix it!!! In this case I haven't a clue why it is happening.

                  Christian EhrlicherC 1 Reply Last reply
                  0
                  • PerdrixP Perdrix

                    @Christian-Ehrlicher Yes, but if I knew how to create the problem, I'd probably know how to fix it!!! In this case I haven't a clue why it is happening.

                    Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    You wanted an answer if you're doing something wrong or if it's a Qt bug. As long as you can't prove that there is a Qt bug (= you can provide a small testcase to reproduce the problem) the answer is - you're doing something wrong. Don't know how we could help here further.

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

                    PerdrixP 1 Reply Last reply
                    1
                    • Christian EhrlicherC Christian Ehrlicher

                      You wanted an answer if you're doing something wrong or if it's a Qt bug. As long as you can't prove that there is a Qt bug (= you can provide a small testcase to reproduce the problem) the answer is - you're doing something wrong. Don't know how we could help here further.

                      PerdrixP Offline
                      PerdrixP Offline
                      Perdrix
                      wrote on last edited by
                      #10

                      @Christian-Ehrlicher Err no, it could still be a Qt problem that I can't work out how to create a small test case for...

                      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