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. Nesting QLayouts vs. nesting QWidgets?
Forum Updated to NodeBB v4.3 + New Features

Nesting QLayouts vs. nesting QWidgets?

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

    Hello,

    I'm creating a UI strictly via Qt Designer that needs some nested layouts. Several layers of VBox and HBox plus a GridLayout or two. The UI is not too complex, but it is more detailed than most Qt examples in the docs.

    Is it better to use a series of nested layouts, or a series of nested "invisible" QWidgets each with a layout for it's children?

    I started with just nested layouts under a QMainWindow, but managing the layout hierarchy via the Object Inspector was difficult. The Qt Designer UI seems lacking here.

    Furthermore, I had to tediously re-create everything every time I broke the layout to add an extra QFrame around some other controls or the like. Not cool.

    Using nested QWidgets seems to make using Qt Designer much more sane, but adding all those extra objects cant be a good thing.

    Which is the best way? Is there a recommended workflow I'm missing?

    Thanks!

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

      Hi,

      Without more info on what your UI should be doing, i'll be asking question in the hope it'll help you.

      If you need so much nesting, are you sure you are using the proper layouts ? Did you took a look at QFormLayout for example ? Or QGroupBox ?

      Do you have several "logic blocks" ? In that case, each might be in its own widget to avoid a one size fits all design while also encouraging re-usability.

      Hope it helps

      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
      • N Offline
        N Offline
        nonot1
        wrote on last edited by
        #3

        Thanks for the reminder about QGroupBox. It'll help in a spot or two. I don't think QFormLayout is applicable, though.

        Setting aside the question of if there is any way to avoid nesting layouts in the first place, I'm still wondering what is the best way to handle nested layouts via Qt Designer.

        What do folks tend to do? (Directly nested, or nesting via QWidgets?)

        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