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. Themes
Forum Updated to NodeBB v4.3 + New Features

Themes

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 958 Views 3 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.
  • R Offline
    R Offline
    Rockerz
    wrote on last edited by
    #1

    How to set dark mode and light mode in qt c++ applications I tried but not work ?

    Pl45m4P Axel SpoerlA 2 Replies Last reply
    0
    • R Rockerz

      How to set dark mode and light mode in qt c++ applications I tried but not work ?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @Rockerz

      Via stylesheet for example.
      What did you try?


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • R Rockerz

        How to set dark mode and light mode in qt c++ applications I tried but not work ?

        Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote on last edited by Axel Spoerl
        #3

        @Rockerz
        Do you want to toggle dark/light mode on...

        • the whole system from C++?
          => not possible, unless you manage to modify your system settings e.g. with a DBussignal or a QProcess to do it on the command line.

        • the application independently from the system in C++?
          => not possible at present. We might implement such a switch at some point, but that's not yet decided.

        • a quick item, a widget? Preferably use setPalette() with the palette of your choice. setStyleSheet()would also work, as @Pl45m4 rightfully wrote. However, it adds a lot of overhead, if the single purpose is just to modify colors.

        Software Engineer
        The Qt Company, Oslo

        S 1 Reply Last reply
        1
        • Axel SpoerlA Axel Spoerl

          @Rockerz
          Do you want to toggle dark/light mode on...

          • the whole system from C++?
            => not possible, unless you manage to modify your system settings e.g. with a DBussignal or a QProcess to do it on the command line.

          • the application independently from the system in C++?
            => not possible at present. We might implement such a switch at some point, but that's not yet decided.

          • a quick item, a widget? Preferably use setPalette() with the palette of your choice. setStyleSheet()would also work, as @Pl45m4 rightfully wrote. However, it adds a lot of overhead, if the single purpose is just to modify colors.

          S Offline
          S Offline
          SimonSchroeder
          wrote on last edited by
          #4

          @Axel-Spoerl said in Themes:

          a quick item, a widget? Preferably use setPalette() with the palette of your choice.

          It would be so nice if this were true. Depending on the operating system (I'm looking at you, Windows!) setting the palette is not sufficient. From my experience I have to say to use style sheets to make your software portable. You can use native calls to be notified of dark mode/light mode changes in the OS.

          Axel SpoerlA 1 Reply Last reply
          0
          • S SimonSchroeder

            @Axel-Spoerl said in Themes:

            a quick item, a widget? Preferably use setPalette() with the palette of your choice.

            It would be so nice if this were true. Depending on the operating system (I'm looking at you, Windows!) setting the palette is not sufficient. From my experience I have to say to use style sheets to make your software portable. You can use native calls to be notified of dark mode/light mode changes in the OS.

            Axel SpoerlA Offline
            Axel SpoerlA Offline
            Axel Spoerl
            Moderators
            wrote on last edited by
            #5

            @SimonSchroeder said in Themes:

            setting the palette is not sufficient

            Tell us more about it, preferably in a bug report!

            Software Engineer
            The Qt Company, Oslo

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SimonSchroeder
              wrote on last edited by
              #6

              From my understanding this is because on Windows the native functions are used for drawing. They don't always respect all palette choices in every single last place. This is what the documentation has to say about this (https://doc.qt.io/qt-6/qapplication.html#setPalette):

              Note: Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines. This is the case for the Windows Vista and macOS styles.

              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