Solved Layout -> Signal when resized
-
Hi there,
short version:
Is there a way to get notified when a layout is resized (like a SIGNAL() I could QObject::connect to)? For example when the user resizes the main window with mouse on a desktop, or when a mobie is turned?Long version:
I want to have an "area" where I can display items one below the other and scroll trough them. This area has a vertical orientation and is part of a grid layout. When I add items to this "area" I want them to be square-shaped with the width and height equal to the width of the "area".
I used to solve that by using a scroll area, attach widgets to it´s mainwidget with incrementals of vertical displacement, resize the mainwidget and update the scrollarea.
May be, there is a smarter way?
At least, if I coud get a notification about the main window beeing resized, I could resize the mainwidget of the scrollarea and it´s sibblings manually.best regards,
Moe -
@Flaming-Moe said in Layout -> Signal when resized:
At least, if I coud get a notification about the main window beeing resized, I could resize the mainwidget of the scrollarea and it´s sibblings manually.
Are you aware that every widget inherits https://doc.qt.io/qt-5/qwidget.html#resizeEvent ? Or there is https://doc.qt.io/qt-5/qobject.html#installEventFilter if you don't want to subclass.
-
@Flaming-Moe said in Layout -> Signal when resized:
At least, if I coud get a notification about the main window beeing resized, I could resize the mainwidget of the scrollarea and it´s sibblings manually.
Are you aware that every widget inherits https://doc.qt.io/qt-5/qwidget.html#resizeEvent ? Or there is https://doc.qt.io/qt-5/qobject.html#installEventFilter if you don't want to subclass.
-
Thanks for the hint - I used the EventFilter. Changed the example to always forward the event and in case the event is of type Resize, it emits a Signal, which is can be connected to a slot.
Think, that will do the job :>