id selector not working in qss in qt 5.7
-
I have a class called mywidget in which i am creating multiple objects of Qpushbutton and i am maintaining a separate qss stylesheet. I am trying to have a separate design for each pushbutton, as per the document "QPushbutton#objectname1{ color:Red}" and "QPushbutton#objectname2{ color:Blue}" should work, but it is not working, is there any other way please help.
-
Mywidget.cpp
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
m_b1= new QPushButton("Submit");
m_b2= new QPushButton("Cancel");
.....
....
.....
QFile file(":/new/xyz.qss");
file.open(QFile::ReadOnly);
stylesheet = QLatin1String(file.readAll());
qApp->setStyleSheet(stylesheet);
}
.qss file
QPushButton#m_b1{
background-color: blue;
border-width: 2px;
border-color: darkkhaki;
border-style: solid;
border-radius: 5;
padding: 3px;
min-width: 9ex;
min-height: 2.5ex;
}
QPushButton#m_b2{
background-color: Red;
border-width: 2px;
border-color: darkkhaki;
border-style: solid;
border-radius: 5;
padding: 3px;
min-width: 9ex;
min-height: 2.5ex;
}