You can use a QTimer with interval of 1s and connect the "timeout()" signal with a slot that change background color
You can use a QTimer with interval of 1s and connect the "timeout()" signal with a slot that change background color
A camel can go 14 days without drink,
I can't!!!
I used QTimer.
for initialization
Qt Code:
connect(timer, SIGNAL(timeout()), this, SLOT(update())); timer->start(1000);To copy to clipboard, switch view to plain text mode
and for stooping timer
You must create a slot (ie. "changeColorSlot()") and connect it to timeout signal
Qt Code:
void MyButton::changeColorSlot() { QColor newColor; if (currentColor == this->color1) newColor = this->color2; else newColor = this->color1; }To copy to clipboard, switch view to plain text mode
Last edited by mcosta; 22nd July 2009 at 13:16. Reason: Use new ColorRole
A camel can go 14 days without drink,
I can't!!!
Hi, just a single optimization suggestion: I would use a int to determinate the state instead of querying the color:
Qt Code:To copy to clipboard, switch view to plain text mode
Bookmarks