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 remove widget's layout w/o deleting it's children widgets?

How to remove widget's layout w/o deleting it's children widgets?

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

    I have MainWindow with many frames created when the application starts. I want to switch between them like that:

    if (this->layout() != Q_NULLPTR) delete this->layout();
    QVBoxLayout *const frame_layout = new QVBoxLayout(ui->frame);
    frame_layout->addWidget(&basicSettings_frame);

    but basicSettings_frame is being deleted, causing error. Do I really should reload all the controls (and recreate the frame before that) every time the user switches between frames or I somehow can tell the frame to not be the child of the layout anymore?

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      No, you don't have to (and should not) recreate the layout contents. Just take the widget out of the layout before you delete. Use takeAt() for that.

      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