I tried this:
void ShiftOpGroup::setThisStyle()
{
"QPushButton { "
"color: white; "
"background-color: "
"qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #08080a, stop: 1 #66777a); "
"border: 6px solid white; "
"border-style: sunken; border-width: 2px; "
"border-radius 6px; border-color: white; }"
"QPushButton:pressed { "
"color: black; background-color: aqua;"
"background-color: "
"qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #eaebfe, stop: 1 #76878a); "
"border-style: raised; border-width: 3px;"
"border-radius 4px; border-color: black;}";
this->setStyleSheet(style);
}
void ShiftOpGroup::setThisStyle()
{
QString style =
"QPushButton { "
"color: white; "
"background-color: "
"qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #08080a, stop: 1 #66777a); "
"border: 6px solid white; "
"border-style: sunken; border-width: 2px; "
"border-radius 6px; border-color: white; }"
"QPushButton:pressed { "
"color: black; background-color: aqua;"
"background-color: "
"qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #eaebfe, stop: 1 #76878a); "
"border-style: raised; border-width: 3px;"
"border-radius 4px; border-color: black;}";
this->setStyleSheet(style);
}
To copy to clipboard, switch view to plain text mode
... but that does nothing.
What I've had to do is to connect the "pressed" and "released" signals of each QPushButton to a slot that sets the style.
Like this ...
class ShiftOpGroup
: public QWidget{
Q_OBJECT
public:
:
:
public slots:
void sbPressed(int);
void sbReleased(int);
:
}
{
:
connect(buttonGroup, SIGNAL(buttonPressed(int)), this, SLOT(sbPressed(int)));
connect(buttonGroup, SIGNAL(buttonReleased(int)), this, SLOT(sbReleased(int)));
:
void ShiftOpGroup::sbPressed(int pbIndex)
{
"color: white; "
"background-color: "
"qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #08080a, stop: 1 #66777a); "
"border: 6px solid white; "
"border-style: sunken; border-width: 2px; "
"border-radius 6px; border-color: white; ";
pShiftButtons->widgetList[pbIndex]->setStyleSheet(style);}
void ShiftOpGroup::sbReleased(int pbIndex)
{
"color: black; background-color: aqua;"
"background-color: "
"qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #eaebfe, stop: 1 #76878a); "
"border-style: raised; border-width: 3px;"
"border-radius 4px; border-color: black; ";
pShiftButtons->widgetList[pbIndex]->setStyleSheet(style);
}
class ShiftOpGroup : public QWidget
{
Q_OBJECT
public:
explicit ShiftOpGroup(QPoint *start, QWidget *parent = 0);
:
QButtonGroup *buttonGroup;
:
public slots:
void sbPressed(int);
void sbReleased(int);
:
}
ShiftOpGroup::ShiftOpGroup(QPoint *start, QWidget *parent) :
QWidget(parent)
{
:
connect(buttonGroup, SIGNAL(buttonPressed(int)), this, SLOT(sbPressed(int)));
connect(buttonGroup, SIGNAL(buttonReleased(int)), this, SLOT(sbReleased(int)));
:
void ShiftOpGroup::sbPressed(int pbIndex)
{
QString style =
"color: white; "
"background-color: "
"qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #08080a, stop: 1 #66777a); "
"border: 6px solid white; "
"border-style: sunken; border-width: 2px; "
"border-radius 6px; border-color: white; ";
pShiftButtons->widgetList[pbIndex]->setStyleSheet(style);}
void ShiftOpGroup::sbReleased(int pbIndex)
{
QString style =
"color: black; background-color: aqua;"
"background-color: "
"qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #eaebfe, stop: 1 #76878a); "
"border-style: raised; border-width: 3px;"
"border-radius 4px; border-color: black; ";
pShiftButtons->widgetList[pbIndex]->setStyleSheet(style);
}
To copy to clipboard, switch view to plain text mode
I have to do that for every QPushButton in every subclass.
There's got to be a better way.
I tried doing it application-wide, and subclass-wide, but it does not seem to work unless I capture the "pressed" and "released" signals for each QPushButton.
Bookmarks