Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Break Layout broken ?



  • Hi,

    Probably newcomer naivety. But I find that if I have say a QDialog, comprising 3 horizontal layouts, and I right-click the last, and choose Break Layout, so that I can add an additional element, then formatting of the other 2 horizontal layouts, breaks, in Qt Creator.

    When I say breaks, formally the other 2 occupied the full width of the QDialog. But after, they shrink horizontally, to take up on-screen, just the space needed by their content.

    I've tried WinMerge compare of the .UI file, before and after, to try and understand what Qt Creator has done, so I can undo it, but cannot fathom the changes.

    I'm using the latest Qt, 5.10, downloaded and installed just a few days ago. I've searched the forum and google on this issue, and not mentioned, per se.

    Best regards,

    David



  • Hi,

    An update. After trying many options, I have managed to prevent the 2 horizontal layouts shrinking when I do a Break Layout on the third horizontal layout.

    I don't know if my solution is an approved way, but for each widget in the 2 horizontal layouts, I have set minimumSize width and height to the actual values shown in geometry, rather than 0.

    And, I have set maximumSize width and height to the same, rather than 16777215.

    But now, another problem. I'll log that as Break Layout broken 2 ?

    Best regards,

    David


  • Lifetime Qt Champion

    Hi
    Breaking a layouts always made contained layouts rescale to much smaller size for me when not a boxgrid.

    Are you sure it used to work differently ?



  • Hi mrjj,

    Thank you very much for your reply, much appreciated.

    Well, I'm really new to Qt, just a few days, so I can't really say about matters working differently in the past.

    I've only every seen the behaviour as described in my 2 posts to this thread.

    Sounds like I need to give boxgrids a try.

    I also have a related issue, per my 'Break Layout broken 2' post. Would you have any insights on that maybe ?

    Must admit, I find the Qt requirement to have to 'Break Layout' to add elements a bit frustration. But maybe layout managers in other products are similar.

    Best regards,

    David


  • Moderators

    @David-King said in Break Layout broken ?:

    I find the Qt requirement to have to 'Break Layout' to add elements a bit frustration.

    You don't need to break a layout to add a new item.

    Just drag the new item onto your existing layout, and the item will be inserted into the layout.


  • Lifetime Qt Champion

    adding to @JKSH , when dragging over a layout, it shows a blueline to
    show where it will be inserted if dropped.

    alt text



  • Ah, but only for 'leaf' items, within a layout.

    But which I mean, I can copy Widget 2, and paste onto Horz Layout fine:

    Horz Layout
    Widget 1
    Widget 2

    I then get:

    Horz Layout
    Widget 1
    Widget 2
    Widget 2_2

    But if I have eg the following, I can't copy Vert Layout, and paste onto Horz Layout:

    Horz Layout
    Vert Layout
    Widget 1
    Widget 2

    So I can't get the following.

    Horz Layout
    Vert Layout
    Widget 1
    Widget 2
    Vert Layout_2
    Widget 1_2
    Widget 2_2

    At least, not without doing a Break Layout on Horz Layout first, to give me:

    Vert Layout
    Widget 1
    Widget 2

    I can then copy-paste Vert Layout, to give me:

    Vert Layout_2
    Widget 1_2
    Widget 2_2

    I can then multi-select Vert Layout, and Vert Layout_2, and choose layout horizontally, to reinstate the layout.

    Problem is, after doing the above, my layout is broken, with all my Horz Layouts (I have 4 so far), laying on top of one other, all at the top of the QDialog.

    How do I know that Break Layout is needed in the scenario described ?

    Because Qt tells me so, via a dialogue it displays, saying that I need to do a Break Layout as described

    On my list, to give boxgrids a try, to see if I get better mileage with..

    Best regards,

    David


  • Lifetime Qt Champion

    Hi
    If you want to clone existing layouts ( to get more)
    Hold down CTRL and drag to clone the selection. (layout and all)



  • Ah, the forum has removed my indenting. Hope makes sense still. Intention was eg:

    Horz Layout
    indent Vert Layout
    indent indent Widget 1
    indent indent Widget 2

    Ie, nested layouts


  • Lifetime Qt Champion

    Hi
    You can drag the layouts with CTRL
    alt text



  • Yo !
    Thank you so much mrjj for CTRL drag !
    I had to be careful I dropped in the right place, but it worked :-)
    I'm sure CTRL drag mention is somewhere in the excellent Qt documentation


  • Lifetime Qt Champion

    @David-King
    One thing i was like 2 years to discover.
    You can drag a selection from the Form to the Widget list.
    And then you can have it there as template. ( in the left side list, bottom)



  • Thanks for the tip !

    So is this post SOLVED I wonder ?
    Well it's worked around, for sure, with CTRL-drag

    Still seems buggish that the layout is broken by a Break Layout, then a reversing of that


  • Lifetime Qt Champion

    @David-King
    Well, depending on what you put in layout and kind of stuff will happen
    when you break it.
    It could be a bug but it does sounds normal to me.
    The red layouts might become the size of what ever is it them and its minimumsize etc.


Log in to reply