Solved How to set styleSheet to all QPushButtons?
-
Hello.
In CSS I have something like:
h1 { color:red; }
which set text color in all h1 to red.
I would like the same in QT ( I don't want use QML ). When I set:
pushButton1->setStyleSheet("QPushButton {color:red;}");
I set the text color only on this "pushButton1". How can I set styleSheet to all QPushButtons in my App ( using code - not uimainWindow )?
-
You can use
QApplication::setStyleSheet
, in themain.cpp
, like thisQApplication app(argc, argv); app.setStyleSheet("QPushButton {color:red;}");
-
@Bonnie And extra question:
Is there any way to add names to QWidgets?
I think about this:
HTML and CSS:
<div id="myDiv"> </div>
and next
#myDiv { height: 500px; width: 500 px; }
So I would like use #Widget
-
@TomNow99 sure, for example:
QPushButton#btnHome { border: 1px solid rgb(87,117,131);}
the text after the # has to be the objectName -property of your widget
-