Solved QWidgets and css file
-
Hi. I'm using a css file, instead to use setStyleSheet function of each components.
The css file permits to set the styleSheet globally.
Is there a way to insert in the css file a style for a particular object for example for a MyButton01 object in the main form? -
Hi
Yes, you can just use selectors
if the button is names MyButton01
you can do
QPushButton#MyButton01 {
}
to apply to buttons named MyButton01Please see
http://doc.qt.io/qt-5/stylesheet-syntax.html
and Selector Types.I also use 1 single stylesheet ( as i qres file)
i set on QApplication and then use
names / types to target the ones i want without setting it directly on the widgets.
This is FAR easier to control over time as stylesheets
on each widgets becomes a mess very fast :)If you only want to apply to pushbuttons in the mainform, you can use
QMainwindow > QPushButton meaning the pushbutton must be a child ( ownerwise)
of a MainWindow type. -
Hi
Yes, you can just use selectors
if the button is names MyButton01
you can do
QPushButton#MyButton01 {
}
to apply to buttons named MyButton01Please see
http://doc.qt.io/qt-5/stylesheet-syntax.html
and Selector Types.I also use 1 single stylesheet ( as i qres file)
i set on QApplication and then use
names / types to target the ones i want without setting it directly on the widgets.
This is FAR easier to control over time as stylesheets
on each widgets becomes a mess very fast :)If you only want to apply to pushbuttons in the mainform, you can use
QMainwindow > QPushButton meaning the pushbutton must be a child ( ownerwise)
of a MainWindow type. -
Perfect!