Reputation: 9634
i am new to QT, i tried lot searching samples of how to get the button paint event in QT.. i am not getting the way to do it..
how to set the delegates for pushbutton in QT?. how to get the paint event for pushbutton?
i read so many articles, it says we can get the paint event of button we can customize too. but i didnt get the piece of code how to get the paint event..
i try doing this sample, by sub classing still i am not getting event. please tell me whre m i wrong
class Mybutton:QPushButton
{
public:
Mybutton(QObject *parent = 0){}
void paintEvent ( QPaintEvent * );
};
void Mybutton::paintEvent(QPaintEvent* Paint)
{
Paint->rect();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPushButton *Newbutton = new QPushButton();
Newbutton->move(20,30);
Newbutton->show();
return a.exec();
}
still i am not able to get the events.
please helpe me in this.
Thanks
Upvotes: 3
Views: 3916
Reputation: 2939
Subclass QPushButton, e.g. class MyButton : public QPushButton...
. You seem to miss public.
the paintEvent is a protected method, so your public override will not work well.
This is not referred to as creating a delegate for QPushButton. What you are doing is that you are sub-classing it and re-implementing its paintEvent.
Upvotes: 0