PDA

View Full Version : qt gridlayout with variable amount of widgets:scrollarea



wouter
28th May 2018, 17:38
Hi,

I have the following problem that I online don't find the solution for:

I have a qt gridlayout and I want the widgets to have a certain minimumsize such that when there are more than X widgets, there comes a scrollarea.

Does anyone know how I can program this?

Its posted in the wrong category, I am searching for how to delete it/repost.

Best regards,
Wouter Devos

d_stranz
29th May 2018, 03:21
Put the QWidget with the QGridLayout as the main widget for a QScrollArea using QScrollArea::setWidget(). Call QScrollArea::setWidgetResizable() with "true". Add your widgets to the grid layout.

Substitute the QScrollArea wherever you were originally using the widget with the QGridLayout.