Scrollarea not working properly on overflow
Unsolved
QML and Qt Quick
-
I have create a scrollarea and inside of it I have put a GridLayout. I dynamically add things (Layouts with Widgets) inside the grid layout at runtime. The Scrollarea though doesn't activate the scrolling when the things overflow.
The code for adding the widgets is this:
void NeuralNetwork::on_hiddenButton_clicked() { int hiddenLayers = ui->layersNum->value()-2; int rNum = std::ceil(hiddenLayers / 3); QSpinBox* hiddenBoxes[hiddenLayers]; QLabel* hiddenLabels[hiddenLayers]; QVBoxLayout* hiddenLayouts[hiddenLayers]; for(int i = 0; i< rNum; i++){ for(int j = 0; j < 3; j++){ hiddenLayouts[i] = new QVBoxLayout; hiddenLabels[i] = new QLabel; hiddenLayouts[i]->addWidget(hiddenLabels[i],1); hiddenLabels[i]->setText("layerNum"); hiddenLabels[i]->show(); hiddenBoxes[i] = new QSpinBox; hiddenLayouts[i]->addWidget(hiddenBoxes[i],0); hiddenBoxes[i]->show(); ui->gridLayout->addLayout(hiddenLayouts[i],i,j); } } }
-
Hi,
You should put that QGridLayout inside a widget that you set on the QScrollArea. See QScrollArea::setWidget