Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt QGraphicsview how to hook to resize event

Tags:

c++

qt

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.

like image 423
mishan Avatar asked Dec 09 '25 20:12

mishan


1 Answers

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

like image 193
TWE Avatar answered Dec 11 '25 09:12

TWE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!