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. I need help on adding layout to layout

I need help on adding layout to layout

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

    I have an main grid which is a QBoxLayout. When I create a layout on designer, using mainGrid->addLayout(layout) doesn't work, but if I create a layout programmatically, it works.

    Now I have a problem, I have created a layout called smallLayout, adding some widgets to it programmatically then using mainGrid->addLayout(smallLayout) to add it to the main grid, everything's fine and dandy. Now I have to move that layout into another grid when users do something in runtime. I used subGrid->addLayout(smallLayout) and it doesn't work, I think it's because I already add widgets to it or put it inside another layout already.

    I don't really understand why that happened? With widgets it's fine when you reassign layout for it but with layout it doesn't work.

    Also do I have to delete all child layout inside mainGrid before closing the program to avoid memory leak?

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

      Hi,

      In that case, wouldn't having a widget to move around be simpler ?

      No you don't, Qt's parent/child relationship will handle that for you.

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

      L 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        In that case, wouldn't having a widget to move around be simpler ?

        No you don't, Qt's parent/child relationship will handle that for you.

        L Offline
        L Offline
        Lynxerious
        wrote on last edited by
        #3

        @SGaist I just don't know why addLayout doesn't work and since there is no discussion about it, I just thought I did something wrong.

        But everything's good now that I set every sub layout to their own groupbox, so the main layout just need to add the groupboxes. Thanks.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by SGaist
          #4

          You're welcome !

          Handling a layout and handling a widget is two different things. If you want to see the gory details, I encourage you to take a look at the layout classes source code.

          Since you have a "workaround", please mark the thread as solved using the "Topic Tool" button so other forum users may know a solution has been found :)

          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
          1

          • Login

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