Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to clear all widgets in QScrollArea ?
Forum Updated to NodeBB v4.3 + New Features

How to clear all widgets in QScrollArea ?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 2.3k 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.
  • sonichyS Offline
    sonichyS Offline
    sonichy
    wrote on last edited by sonichy
    #1

    Why I can not clear all widgets in QScrollArea ?

    QLabel *label = new QLabel;
    label->setText("FIFA");
    ui->verticalLayout_shedule->addWidget(label,0,Qt::AlignTop);
    ...
    QLayoutItem *child;
    while ((child = ui->verticalLayout_shedule->takeAt(0)) != 0) {
        delete child;
    }
    

    alt text

    https://github.com/sonichy

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      You only take the items out.
      the items also contains the actual widget.

      void MainWindow::on_toolButton_released()
      {
          QLayoutItem *child;
          while ((child = ui->verticalLayout->takeAt(0)) != 0) {
              delete child->widget(); // get rid of widget too
              delete child;
          }
      }
      
      
      1 Reply Last reply
      4

      • Login

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