Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to get native OS colors
Forum Updated to NodeBB v4.3 + New Features

How to get native OS colors

Scheduled Pinned Locked Moved Solved Qt for Python
8 Posts 2 Posters 912 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.
  • F Offline
    F Offline
    fvez_demtroys
    wrote on last edited by
    #1

    Hi,

    I am currently working on a PyQt5 application with Python 3.9.0.

    I would like to get the native operating system colors to apply them to my QPushButton.
    I would like the "send" button in the attached image to have the same color as the "single device" tab.
    This is also the color shown when pressing the button.
    screenshots
    I hope the link works, I am not too familiar with imgur.

    Is there a way for me to obtain these native colors? I haven't been able to find any relevant information on this and I doubt I am the only one trying to do this.

    Thanks for the help!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      If memory serves well it should happen if you make it the default button. See QDialogButtonBox.

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

      1 Reply Last reply
      1
      • F Offline
        F Offline
        fvez_demtroys
        wrote on last edited by
        #3

        Hi SGaist,

        Thanks for the quick reply. Yes this works, I used the setDefault function on the button.

        Still, is there a way to obtain these colors? Lets say I wanted to apply it to something other than a button. Is there a similar method for the other object types?

        As a random example, lets say I wanted this color as the background of a group box, would that be possible?

        Thanks!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          That's not a good idea. You would go against the platform user interface guidelines which is something that your users won't like.

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

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fvez_demtroys
            wrote on last edited by
            #5

            Hi SGaist,

            Why wouldn't this be a good idea? I just want to obtain the default OS colors and apply them to some widgets.
            I could decide to recolor everything the same shade of blue but I would prefer to obtain the actual OS colors.
            The users are myself and a few colleagues, this is an internal tool.

            Is there a way to do this?

            Thanks!

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Because that kind of highlighting is used for specific purposes. Applied it to any and all controls does not make things clearer. Rather the contrary. Why would a QGroupBox all of a sudden get the same blue background as a selected tab ?

              You can get the information from QPalette.

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

              1 Reply Last reply
              0
              • F Offline
                F Offline
                fvez_demtroys
                wrote on last edited by
                #7

                Hi SGaist,

                Thanks for the clarification, that does make sense.
                We weren't planning on using the color for anything other than buttons but were curious to see if it was available.

                However, when playing around with QPalette, we were unable to obtain the color we mentioned in our previous post.
                Any idea which field is the one we are looking for?
                We tried all of the ColorRoles and the ColorGroups.

                Thanks for the information, very appreciated!

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  I would have gone with QPalette::Highlight

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

                  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