QPushButton Red to Green and Green to Red Question
OK. Quick question: When I click on my button it goes from red to green, however, when I want to turn the button off, it does not turn back to red. Does anyone have any suggestions.
Code:
button->setChecked(true);
button
->setStyleSheet
(QString("QPushButton {background-color: red;}"));
connect(button,SIGNAL(pressed()),this,SLOT(onoff()));
void Dialog::onoff()
{
button->setChecked(false);
button
->setStyleSheet
(QString("QPushButton {background-color: green;}"));
*
*
Re: QPushButton Red to Green and Green to Red Question
Yes, use the :pressed pseudo-state.
Re: QPushButton Red to Green and Green to Red Question
Quote:
Originally Posted by
wysota
Yes, use the :pressed pseudo-state.
I think :checked pseudo-state is better because the :pressed pseudo-state is on when the mouse button is pressen on the button.