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. Qt Layout woes !
Qt 6.11 is out! See what's new in the release blog

Qt Layout woes !

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 753 Views 3 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.
  • A Offline
    A Offline
    ArshadM
    wrote on last edited by
    #1

    I am having a really hard time trying to understand Qt layout semantics.

    Basically, I used designer to create a signup form derived from QWidget. This has no layout defined at the root level, and everything is positioned absolutely, and it all looks good in the designer and in preview.

    The mainwindow has a stacked widget as the central widget and I added a page to it. This page has a vertical layout defined, and I added the signup form to it. The signup form is left aligned and centred if I don't add any alignment options.

    IF however, I explicitly set it to right aligned then it disappears from the UI altogether. After doing some experimentation, it looks I cannot right align unless every widget is in an explicit layout.

    I know I probably should be using layouts throughout to make things more fluid, but unfortunately it's quite a complex form and I don't want to make it look like the average generic form UI.

    My question is, what's wrong with having a widget that's got an explicit size set on it (as my signup form has, it has a resize() call in the UI definitions) in being added to a vertical layout and being right aligned?

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

      Hi and welcome to devnet,

      Please provide a minimal compilable example that shows that behaviour.

      Also what version of Qt are you using ?
      On what OS ?

      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
      • A ArshadM

        I am having a really hard time trying to understand Qt layout semantics.

        Basically, I used designer to create a signup form derived from QWidget. This has no layout defined at the root level, and everything is positioned absolutely, and it all looks good in the designer and in preview.

        The mainwindow has a stacked widget as the central widget and I added a page to it. This page has a vertical layout defined, and I added the signup form to it. The signup form is left aligned and centred if I don't add any alignment options.

        IF however, I explicitly set it to right aligned then it disappears from the UI altogether. After doing some experimentation, it looks I cannot right align unless every widget is in an explicit layout.

        I know I probably should be using layouts throughout to make things more fluid, but unfortunately it's quite a complex form and I don't want to make it look like the average generic form UI.

        My question is, what's wrong with having a widget that's got an explicit size set on it (as my signup form has, it has a resize() call in the UI definitions) in being added to a vertical layout and being right aligned?

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        @arshadm said in Qt Layout woes !:

        My question is, what's wrong with having a widget that's got an explicit size set on it (as my signup form has, it has a resize() call in the UI definitions) in being added to a vertical layout and being right aligned?

        If you put the form itself inside a layout, then the layout can overrule your resize() instructions. It is the layout's job to call resize() on every widget that it manages.

        The outer layout will query your form to find out how much visual space it needs. Because your form contains no layout, it will happily tell the outer layout that it needs 0 width and 0 height. Therefore, the "outer" layout calls resize(0, 0) on your form.

        To change this behaviour, set your form's minimum size. Alternatively, you can specify a size policy for your form.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        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