Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Minimum widget size to cover QScrollArea viewport?
What is the best way to get the width and height of the visible portion of a QScrollArea viewport? I need to manually set the height of the widget because the height always matches the viewport size but the width might be bigger depending on the level of custom zoom (it's a timeline widget). It would also be ideal to get this prior to showing the scroll area, or at least after QScrollArea::show() is called but before it is animated horizontally on screen.
I found the following inaccurate in all cases:
VRonin last edited by mrjj
I need to manually set the height of the widget because the height always matches the viewport
Then it's probably easier to just set
@VRonin That should adjust the viewport to my widget size, correct? But I need to adjust my widget size to the visible rect of the scroll area. Or am I misunderstanding this?
Out of curiosity, what kind of widget are you putting in that QScrollArea ?
@SGaist It is a custom timeline widget which shows events chronologically going from left to right, and zooms by simply expanding the width of the widget on vertical wheel events. The vertical scale of the widget always remains the same. Events are laid out to scale horizontally so you get a sense of relative time between them.
So the height of the widget needs to always be the height of the scroll area viewport so it never scrolls vertically, and the widget needs to always be at minimum the width of the viewport, or a positive multiple of the width of the viewport as determined by the level of zoom.
Wouldn't a model and a custom view be simpler to handle that kind situation ?