Search code examples
qtuser-interfacepysideqtgui

Remove 'selected' highlighting of Qt/PySide widget


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?


Solution

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

    QWidget.setFocusPolicy(QtCore.Qt.NoFocus)