Important: Please read the Qt Code of Conduct -

QScrollArea in QGridLayout in multiple cells

  • Hello,

    I want to add a QScrollArea to a QGridLayout in multiple cells, but the QScrollArea does not use all horizontal space availavble.
    I added it like this: layout->addWidget(scrollArea, 0, 0, 1, 2, Qt::AlignCenter);

    The ScrollArea is in the center, but it does not use all horizontal space available. How do I do this?

  • Lifetime Qt Champion

    I think you need to say
    ui->scrollArea->setWidgetResizable( true );

  • @mrjj
    You're probably/doubtless right, but could you explain

    If this property is set to true, the scroll area will automatically resize the widget in order to avoid scroll bars where they can be avoided, or to take advantage of extra space.

    It may fill the cell initially to "take advantage of extra space", as per OP's requirement, but when it gets filled with content will it "resize the [cell] widget to avoid scroll bars" when we want it to stay same size and scroll instead?

Log in to reply