Important: Please read the Qt Code of Conduct -

Why are scroll area's preferred sizes bounded to some magic values?

  • In QScrollArea::sizeHint(), the return value is bounded to 36fontHeight / 24fontHeight:
    @int h = fontMetrics().height();
    return sz.boundedTo(QSize(36 * h, 24 * h));
    In QGraphicsView::sizeHint(), the return value is bounded to 3/4 of the desktop size:
    @baseSize = baseSize.boundedTo((3 * QApplication::desktop()->size()) / 4);

    Why is this implemented as the default behavior? It puts some restrictions on using QScrollArea or QGraphicsView in a layout, since the layout might not resize the component as large as it could, but instead showing scrollbars while there is still enough space available around the scroll area.

    The solution is certainly to subclass QScrollArea/QGraphisView and reimplement sizeHint() without the boundedTo() call, but should this not be the default behavior of the framework?

  • Hi and welcome to devnet,

    I think you have a point there.

    You can fill a feature request on the "bug report system": and post the link here, so others can vote for it.

    [edit: Corrected link SGaist]

  • Hi Eddy,

    thanks for your reply. Just wanted to check if I missed something obvious with those restrictions ;)

    Here is the link to the bug (I think its a bug rather than a feature request):


Log in to reply