Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a style sheet that only affects the parent in PyQT?

I'm trying to customize my UI. I don't know how to make a style sheet entry pertain to anything except the parent and ALL of the children. For example I run this line:

self.lnchTab.setStyleSheet('QWidget { background-color: #1d1d1d ; color: #f8f8f8}')

And I change ALL of the elements beneath self.lnchTab to be darkish grey. I want only the self.lnchTab to be dark grey, and not the text, inputs, and buttons within it.

How do I accomplish this?

Thanks for any help. Google is giving nothing useful or even near what I'm trying to find.

like image 711
Vii Avatar asked Jun 12 '12 10:06

Vii


1 Answers

You can give self.lnchTab object some name/id and then you can use id-selector in style-sheet:

self.lnchTab.setObjectName("myParentWidget");
self.lnchTab.setStyleSheet('QWidget#myParentWidget { background-color: #1d1d1d ; color: #f8f8f8}')
like image 69
Ammar Avatar answered Sep 30 '22 14:09

Ammar