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 move a layout to a new parent?
Forum Updated to NodeBB v4.3 + New Features

How to move a layout to a new parent?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.9k 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    Is is possible to re-parent a layout? I've been trying to do it all day but have not had any success. Here are the details:

    I have a group of widgets (a couple text edits and labels) that form a UI element in my app. I have them grouped in a VBoxLayout. Sometimes (depending on the options the user selects) I want this group to show up on a particular TabWidget tab that's a child of my dialog. Sometimes I want the group to show up directly on the dialog, with the TabWidget hidden.

    To put it graphically, sometimes I want MyMovableLayout to appear in this hierarchy:

    QDialog -> TopLayout -> QTabWidget -> Tab -> MyMovableLayout

    and sometimes I want:

    QDialog -> TopLayout -> MyMovableLayout.

    I've tried a variety of setParent()/addLayout()/insertLayout()/show()/hide() combinations, but nothing seems to work. I can never get the layout to show up under the TopLevel layout.

    Any suggestions?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Nope, there is no such method. I would suggest you group the items as a widget instead of in just a layout. Just apply the layout to that new widget, and put the content-widgets in that layout. Now, you can reparent the whole widget in one go.

      on a side note: this is my 2^12 post on DevNet! I made it just before the move to qt-project.org :-)

      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