0

I'm using a stylesheet to customise the look of my Qt/Pyside buttons. When I open the application, the first button is 'highlighted' with a coloured overlay (it moves through the GUI elements when I use the arrow keys). I want to remove this highlighting. I tried:

QPushButton, QPushButton:selected { 
  color: rgb(50, 50, 50); 
  background-color: rgba(188, 188, 188, 50); 
  border: 1px solid rgba(188, 188, 188, 250); 
  border-radius: 3px;
} 

but the overlay doesn't go away. I've also tried the most relevant the pseusostates specified here

http://qt-project.org/doc/qt-4.8/stylesheet-reference.html#list-of-pseudo-states

instead of ':selected' but with no luck. How can I get rid of this highlighting?

Saar Drimer
  • 1,171
  • 2
  • 11
  • 24

1 Answers1

2

As a simple workaround you could disable the focus on all elements you don't want to be highlighted:

QWidget.setFocusPolicy(QtCore.Qt.NoFocus)
NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
  • YES! That did it. After posting my question, I figured that this would be a better approach but haven't had the time to search for it. This is clearly a better solution, and not a 'workaround' ;) – Saar Drimer Jul 14 '14 at 12:33
  • 1
    not a solution, because with NoFocus, QSpinBox cannot be modified via mouse wheel – iperov Mar 23 '22 at 13:22
  • In addition, it is only a workaround rather than a solution, since presentation style should have an ability to control the focus overlay behavior/color, rather than removing the whole focus capabilities from code. – Meir Kriheli Aug 31 '23 at 07:37