You got the idea,
Call update() in void theGui::mouseMoveEvent(QMouseEvent *event), not in theGui::drawRect(QPoint _s, QPoint, _e) (rename it drawRectSelection(QPoint _s, QPoint, _e) to avoid confusion QPainter:rawRect(etc...)) .
No need to calll drawRect(startPoint,event->pos()) in void theGui::mouseMoveEvent(QMouseEvent *event);
Use your flag in theGui:aintEvent(QPaintEvent *event) and do the painting of the selection rectangle in this function only.
Or you can use QRubberBand as suggested...
Bookmarks