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. How to change the color of the focus Widget in QT?
Forum Updated to NodeBB v4.3 + New Features

How to change the color of the focus Widget in QT?

Scheduled Pinned Locked Moved General and Desktop
focuswidgetcolor change
5 Posts 3 Posters 7.8k 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.
  • F Offline
    F Offline
    ForestPoem
    wrote on last edited by ForestPoem
    #1

    How to change the color of the focus Widget in QT?

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

      Hi
      You mean what ever widget that has keyboard focus ?

      F 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        You mean what ever widget that has keyboard focus ?

        F Offline
        F Offline
        ForestPoem
        wrote on last edited by ForestPoem
        #3

        @mrjj
        Thank you, Button widget focus.

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The issue is a little bit more complicated than you might think, as there might simply not be a "color of a button". Some styles on some OSes might use a gradient, an outline or even animate the button on hover/focus/click etc.
          That being said you can override the background color of a button when it's focused like this:

          yourButton->setStyleSheet("QPushButton:focus {  background-color: red; }");
          

          but be aware that this will disable native styling of the button so on some platforms/themes it will look out of place.

          F 1 Reply Last reply
          1
          • Chris KawaC Chris Kawa

            The issue is a little bit more complicated than you might think, as there might simply not be a "color of a button". Some styles on some OSes might use a gradient, an outline or even animate the button on hover/focus/click etc.
            That being said you can override the background color of a button when it's focused like this:

            yourButton->setStyleSheet("QPushButton:focus {  background-color: red; }");
            

            but be aware that this will disable native styling of the button so on some platforms/themes it will look out of place.

            F Offline
            F Offline
            ForestPoem
            wrote on last edited by
            #5

            @Chris-Kawa

            Thanks to you I've been able to solve

            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