You probably want to change the stylesheet every time you click the button?
http://doc.trolltech.com/4.6/qwidget...tyleSheet-prop
Edit:
Ah, i saw that was already linked earlier. Something similar to this should give you an idea how you could achief this.
class yourwindow
{
...
private:
int buttonstate ;
QButton * btn;
private slots:
void btnClicked();
}
//setup the button somewhere
buttonstate = 0;
btn = new QButton(this);
connect(btn, SIGNAL(clicked), this, SLOT(btnClicked));
void yourwindow::btnClicked()
{
switch(buttonstate)
{
case 0: btn
->setStyleSheet
(QString::fromUtf8("QButton { background: red; }"));
break;
case 1: btn
->setStyleSheet
(QString::fromUtf8("QButton { background: blue; }"));
break;
case 2: btn
->setStyleSheet
(QString::fromUtf8("QButton { background: green; }"));
break;
default: break;
}
buttonstate++;
if(buttonstate > 2)
buttonstate = 0;
}
class yourwindow
{
...
private:
int buttonstate ;
QButton * btn;
private slots:
void btnClicked();
}
//setup the button somewhere
buttonstate = 0;
btn = new QButton(this);
connect(btn, SIGNAL(clicked), this, SLOT(btnClicked));
void yourwindow::btnClicked()
{
switch(buttonstate)
{
case 0: btn->setStyleSheet(QString::fromUtf8("QButton { background: red; }")); break;
case 1: btn->setStyleSheet(QString::fromUtf8("QButton { background: blue; }")); break;
case 2: btn->setStyleSheet(QString::fromUtf8("QButton { background: green; }")); break;
default: break;
}
buttonstate++;
if(buttonstate > 2)
buttonstate = 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks