Important: Please read the Qt Code of Conduct -

QWidget.hide() interrupts mouseMoveEvent()

  • Hello,

    I would like to make my application so as to have a QRubberband for selecting a region on a QScrollArea's child widget (Document). Whenever a selection is made, a Mask (a semi-transparent QFrame) shows up on the Document. Whenever a new selection is made with the rubberband, i.e. on mousePressEvent(), the Mask should hide while the selection is being made, and turn visible only after the selection process has been completed.

    The rubberband on its own functions perfectly. As I introduced the Mask however, with a Mask.hide() in the mousePressEvent(), the hide() method call interrups the mouseMoveEvent(). i.e. subsequent method calls do not occur and there is not error message returned. I have tried to place the Mask.hide() in the mouseMoveEvent() to test out, and in the same way, all method calls following the Mask.hide() do not work.

    How is this possible? Is it a bug or am I doing the wrong thing?


  • For now I have worked around this "bug" by creating a QWidget and reimplementing its paintEvent() with a forked option (either fillRect() or pass) and forcing an update() whenever changes are required. It might even be a better idea than using hide() / show(). Or isn't it?

Log in to reply