I write a program that draws a specific field, and then by clicking the mouse, certain data changes, on the basis of which the object is drawn. So, I need the program to return to an already executed paintevent after executing the mousepressevent, and to execute its part again. How would I implement this?
1 answer
If you want to call the widget redrawing immediately, then this is done using the QWidget::repaint() method, which in QWidget has several variations, so that you can specify not only a rectangular selection ( QRect ) to redraw, but also various geometrical areas ( QRegion ).
However, in most cases it is better to use QWidget::update() , which will call the widget redraw in the event queue and, if there are several identical in the queue, redraw the widget only once, grouping the events automatically. The arguments to the update() method are the same as those for repaint() .
If the parameters during redrawing do not touch the actual coordinates of the redrawing area, but must be of an arbitrary character, then additional flags are added, which inside the redraw event handler will form the corresponding execution logic.