user2345
user2345

Reputation: 537

Getting default Stylesheet in Python QT widgets

How can i get the default stylesheet colors in python using pyqt

I assigned a StyleSheet for a QGroupBox when its activated

self.State.setStyleSheet("QGroupBox { background-color: rgb(0,255,0,20%); border:1px solid rgb(255, 170, 255); }") 

I need to have it set to defaults when this particular QGroupBox is disabled or deactivated

Upvotes: 3

Views: 6436

Answers (2)

Guimoute
Guimoute

Reputation: 4649

To restore a previous non-default stylesheet, you can do as Felipe Lema suggests.

To restore a default one, you can use an empty string and call directly:

self.State.setStyleSheet(""). 

Upvotes: 0

Felipe Lema
Felipe Lema

Reputation: 2718

You can save it to a string before changing it (it's a R/W property):

default_style_sheet = self.State.styleSheet()

# ...

self.State.setStyleSheet(fancy_style_sheet)

# ...

self.State.setStyleSheet(default_style_sheet)

Upvotes: 0

Related Questions