QScrollArea nested layouts
I got some problems with the QScrollArea. Following code creates a Qt3DWindow in a windowContainer.
This container is embedded in a QHBoxLayout along with a QVBoxLayout which contains several other widgets (like buttons).
For the case that the QVBoxLayout gets stuffed with too many widget I would like to make i scrollable but my approaches were not satisfying.
original code which works fine (without scrolling):
QWidget* container = QWidget::createWindowContainer(view); // view => Window3D QSize screenSize = view->screen()->size(); container->setMinimumSize(QSize(200, 100)); container->setMaximumSize(screenSize); QWidget* widget = new QWidget; QHBoxLayout* hLayout = new QHBoxLayout(widget); QVBoxLayout* vLayout = new QVBoxLayout; vLayout->setAlignment(Qt::AlignTop); hLayout->addWidget(container, 1); hLayout->addLayout(vLayout);
QWidget* widget = new QWidget; QHBoxLayout* hLayout = new QHBoxLayout(widget); QWidget* widget2 = new QWidget; QVBoxLayout* vLayout = new QVBoxLayout(widget2); vLayout->setAlignment(Qt::AlignTop); hLayout->addWidget(container, 1); hLayout->addWidget(widget2); QScrollArea* area = new QScrollArea; area->setWidget(widget); // whole layout is scrollable //area->setWidget(widget2); // only vLayout is displayed (and scrollable) area->setWidgetResizable(true);
This is from the Qt3D example "basicshapes". I want to make the verticalLayout at the right scrollable while the 3D view container stays the same size. The original code from above belongs to this.