View Full Version : Qtoolbutton style
offline
4th April 2010, 12:19
Hi all
i have to QToolButton. i want to give efect a button.
borisbn
4th April 2010, 12:55
QWidget::styleSheet (http://qt.nokia.com/doc/4.6/qwidget.html#styleSheet-prop)
and read about styleSheets (http://qt.nokia.com/doc/4.6/stylesheet.html)
offline
4th April 2010, 14:17
Click the button to change the efect is exactly what I should do.
borisbn
4th April 2010, 14:41
Honestly, I didn't understand neither the first time nor now.
What the effect (or effect of what) do you want to change?
offline
4th April 2010, 16:14
I want to make a flash like a button. I'm click give different effects.
GreyHound
4th April 2010, 16:33
You probably want to change the stylesheet every time you click the button?
http://doc.trolltech.com/4.6/qwidget.html#styleSheet-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;
}
offline
4th April 2010, 17:28
thanks.
when i click on the button , i want to have shining.
aamer4yu
5th April 2010, 07:15
Depends on how you define shining.
You could have some image overlay to create shining, you could paint the shining yourself,
May be also you can have a look at QGraphicsEffect class.. it works with widgets and may be colorize might help you.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.