Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Scrollarea not working properly on overflow
QtWS25 Last Chance

Scrollarea not working properly on overflow

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
scrollareaqt5.5runtimegridlayout
2 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • AthanDA Offline
    AthanDA Offline
    AthanD
    wrote on last edited by
    #1

    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);
            }
        }
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should put that QGridLayout inside a widget that you set on the QScrollArea. See QScrollArea::setWidget

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved