Issue
Using PyQt, is there any way to change the stylesheet for every instance of a widget without having to manually change each widget's stylesheet.
Say, for instance, I wanted every pushbutton in my application to have red text. How would I do this without having to run button.setStyleSheet()
for each button? Could there possibly be a way to change PyQt's stock button class?
Any help would be appreciated :)
Solution
Set the style sheet of your QApplication
instance to change the style of specific widgets globally, e.g.:
GLOBAL_STYLE = """QPushButton {
color: red;
}"""
class MyApp(QMainWindow):
# your ui code here
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setStyleSheet(GLOBAL_STYLE)
main = MyApp()
main.show()
sys.exit(app.exec_())
Answered By - jfaccioni
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.