Qt QGraphicsview how to hook to resize event

c++, qt

Solution

If you have a QWidget you only need to reimplement the `resizeEvent` function.

void QWidget::resizeEvent ( QResizeEvent * event ) [virtual protected]

In the Qt documentation you can find the scribble example for a full code example: http://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html

Alternatively you can install an event handler and grab the `QEvent::Resize`. How to install event filters is described here: http://qt-project.org/doc/qt-4.8/eventsandfilters.html

Problem

we're working on a Qt C++ Widget project and recently ve'we run into trouble. We're Qt rookies. On our widget there are two `QGraphicsView` which need to resize automatically when the window is resized (we've done that) and keep the content inside them resized/fit/scaled accordingly to... So we've figured we need to somehow hook to `onResizeEvent` or find which slot does it. But we're somehow lost as to how to do it. P.S.: Please excuse my english.

Original source