When do QWidget parent methods need to be called?
Unsolved
General and Desktop
-
It's a little unclear to me when parent methods need to be called.
Is it always/ever necessary to call the parent method when overriding in a subclass?
void resizeEvent(QResizeEvent* ev) override { QWidget::resizeEvent(ev); ... }
Eg for:
void mousePressEvent(QMouseEvent*)
void mouseMoveEvent(QMouseEvent*)
void mouseReleaseEvent(QMouseEvent*)
void moveEvent(QMouseEvent*)
void resizeEvent(QResizeEvent*) -
Hi,
It depends on what your subclass does and if it needs the original behavior to take place.
-
From the documentation (http://doc.qt.io/qt-5/qobject.html#event): "Make sure you call the parent event class implementation for all the events you did not handle."
See the link for sample code.