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. QWidget don't change color theme on macOS under specific circumstance
Qt 6.11 is out! See what's new in the release blog

QWidget don't change color theme on macOS under specific circumstance

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 296 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.
  • S Offline
    S Offline
    Sky Lian
    wrote on last edited by
    #1

    Qt 6.5.0
    macOS 13.2.1

    int main(int argc, char **argv) {
        QApplication a(argc, argv);
    
        QScrollarea window;
        QWidget widget;
        QGridLayout layout(&widget);
    
        widget.setStyleSheet(R"--(.QLabel[wordWrap="false"]:focus {
            border-radius: 12px;
            border: 8px solid rgb(22, 185, 255);
        })--"); // I know widget has no QLabel children; some valid stylesheet is the point
        window.setWidget(&widget);
        window.show();
        return a.exec();
    }
    

    Run, change appearance in system setting, and then:
    Screenshot 2023-04-11 at 22.52.33.png

    SGaistS 1 Reply Last reply
    0
    • S Sky Lian

      Qt 6.5.0
      macOS 13.2.1

      int main(int argc, char **argv) {
          QApplication a(argc, argv);
      
          QScrollarea window;
          QWidget widget;
          QGridLayout layout(&widget);
      
          widget.setStyleSheet(R"--(.QLabel[wordWrap="false"]:focus {
              border-radius: 12px;
              border: 8px solid rgb(22, 185, 255);
          })--"); // I know widget has no QLabel children; some valid stylesheet is the point
          window.setWidget(&widget);
          window.show();
          return a.exec();
      }
      

      Run, change appearance in system setting, and then:
      Screenshot 2023-04-11 at 22.52.33.png

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Just an educated guess: setting a stylesheet triggers the use of a different style which replaces the one that mimics the system thus it might not be theme aware.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Just an educated guess: setting a stylesheet triggers the use of a different style which replaces the one that mimics the system thus it might not be theme aware.

        S Offline
        S Offline
        Sky Lian
        wrote on last edited by Sky Lian
        #3

        @SGaist
        There're another 2 necessary factors beside stylesheet: QScrollArea & QGridLayout.

        And another observation: go through it: print widget and window palette's rgb, delay printing to 3s later, and switch appearance; you will find that widget palette's RGB hasn't changed, but window palette's has.

        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