0

What I want to do is to show new QWidget, which is set in QScrollArea. The Grid Layout is set in Scroll Area and than VBox Layout is added to the Grid one.

Program allows to add dynamically Labels in this VBox Layout. I want scroll area has fixed size and when area taken by Labels exceeds scroll area's size (heigth), than scrollbar should appear (and no changes in Scroll Area size).

With my code - adding Labels causes increasing heigth of QWidget (window). Scrollbar can be seen at the beginning but at some point it disappears... like QScrollArea is no more in there...

QWidget* playlistWindow = new QWidget();
playlistWindow->setAcceptDrops(true);
playlistWindow->resize(200, 300);

QScrollArea* scrollArea = new QScrollArea();
scrollArea->setWidget(playlistWindow);
QVBoxLayout* layout = new QVBoxLayout();
QGridLayout* gridLayout = new QGridLayout();
layout->setAlignment(Qt::AlignTop);
scrollArea->setLayout(gridLayout);
gridLayout->addLayout(layout, 0, 0);
scrollArea->setMaximumHeight(300);

scrollArea->show();   
WJuz
  • 37
  • 1
  • 6
  • Hmm, I can add that in form everything works fine... I have QScrollArea with GridLayout and VBoxLayout in GridLayout... but dynamically I made some mistake... – WJuz Aug 28 '16 at 19:00
  • Ok, I managed to implement that with no problems using Qt Designer with form... but I also would like to be able to do it stricte from code level... I'll try to look sth up, every help would be nice :) – WJuz Aug 29 '16 at 14:18

0 Answers0