Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. No scrolling in ScrollArea
Qt 6.12 LTS is out! See what's new in the release blog

No scrolling in ScrollArea

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 531 Views 1 Watching
  • 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.
  • A Offline
    A Offline
    Alfie Anil
    wrote on last edited by
    #1

    Hello everyone,
    I have implemented a QScrollArea into a widget. However, When I add multiple data into the scroll area, it just shrivels the data together and doesn't allow for the scroll functionality. Here is the code the code I have used:

    
            while(query->next())
            {
                QString title = query->value(0).toString();
                qDebug() << title;
                titles.push_back(title);
    
                QString link = query->value(1).toString();
                qDebug() << link;
                links.push_back(link);
    
                QString image = query->value(2).toString();
                qDebug() << image;
                images.push_back(image);
            }
    
    
        } else{
            qDebug() << "Couldn't connect";
        }
    
        QScrollArea *scrollArea = new QScrollArea(this);
        QVBoxLayout *layout = new QVBoxLayout;
    
        ui->mainWidget->setLayout(layout);
        layout->addWidget(scrollArea);
    
        QVBoxLayout *scrollLayout = new QVBoxLayout;
        scrollArea->setLayout(scrollLayout);
    
        for(int i=0; i<10; ++i){
            QWidget *tempWidget = new QWidget;
            QHBoxLayout *tempLayout = new QHBoxLayout;
    
            tempWidget->setLayout(tempLayout);
            QLabel *label = new QLabel("Test");
    
            tempLayout->addWidget(label);
            scrollLayout->addWidget(tempWidget);
        }
    
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Because you are doing it wrongly. Your scrollLayout should be applied to a widget that you set on the QScrollArea.

      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
      • Unsolved