Search code examples
pythonqtpyqtpyqt4stylesheet

PyQt4 Widgets's component names for stylesheet


I am trying to learn to create external qss files (stylesheets) for my python program that is written in PyQt for fancier look.

enter image description here

In the Qt stylesheet examples, it used this

 QTableView QTableCornerButton::section {
 background: red;
 border: 2px outset red;

}

to specifi the style properties of the connerbutton(red rectangle) on QTableWidget. However, it doesn't say how the other component names should be addressed. For example, i have no idea how to change the horizontalheaderlabel and verticalheader styles.

When i use a stylesheet without using any component names (like QTableCornerButton) like this

    QTableWidget {
     selection-background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5,
                                 stop: 0 #579599, stop: 1 #39B4BD);
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #D1DBEB, stop: 0.4 #C0D1EB,stop: 0.5 #ABBEDB, stop: 1.0 #95ABCC);
border:1px solid #7286A3;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
border-bottom-left-radius: 9px;
border-bottom-right-radius: 9px;
padding:0px;

 }

It applies the style to the whole widget instead of particular areas.

Where can i find the names for the widget's components that is supported by stylesheets ( For example, QTableCornerButton) online?

Qt Stylesheet example is good but it does not provide all the names and properties i can use.


Solution

  • Have you looked at documentation here?