How to get the painting event for buttons in QT

advertisements

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


You need to subclass QPushButton and reimplement paintEvent().