I am trying to make a QGridLayout scrollable. It may contain several custom widgets, the number of widgets is not fixed. QGridLayout must be scrollable when there are more than x widgets, x being an arbitrary number.
The problem is, when I use QScrollArea, QScrollArea seems to hide the whole layout (only the background color of scroll area is shown). When I use QGridLayout alone, my view is - of course - not scrollable but everything works as it should do.
I am probably missing something, my guesses are:
- I must fix somehow the size of the scrollable area, but I am not sure it's necessary or if I already have done it unconsciously
- Parent Widgets or Child Widgets of the existing QScrollArea prevent QScrollArea by an unusual implementation to act normally.
Here's a piece of the involved code :
QScrollArea *scrollArea = new QScrollArea;
QWidget *resultsPage = new QWidget;
booksGrid = new QGridLayout;
booksGrid->setSizeConstraint(QLayout::SetMinAndMaxSize);
resultsPage->setLayout(booksGrid);
scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(resultsPage);
mainWidget->addWidget(scrollArea);
Also, booksGrid is declared as a class attribute, mainWidget is a QStackedWidget.
Any help is welcomed, let me know if you need more information !



booksGrid->setSizeConstraint(QLayout::SetMinAndMaxSize);out? - Scheff's Cat