How to get a drawing event for buttons in QT

I am new to QT, I have tried a lot to look for samples of how to get a button draw event in QT .. I do not get a way to do this.

How to set delegates for a button in QT ?. How to get a drawing event for a button?

I read so many articles, he says that we can get a button draw event, which we can also customize. but i did not get a piece of code how to get a drawing event.

I am trying to make this example, on a sub class, but I am not getting an event. please tell me I'm 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 can't get events.

please help me with this.

thank

+3
source share
2 answers

QPushButton reimplement paintEvent().

+3
  • QPushButton, . class MyButton : public QPushButton.... , , .

  • paintEvent - , .

  • QPushButton. , , paintEvent.

0

Source: https://habr.com/ru/post/1732307/


All Articles