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

Copy and paste form does not maintain layout



  • Up front - I DO REALIZE I MAY BE PUSHING THE ENVELOPE.

    I prefer NOT to reinvent the wheel, however,
    I have not been very successful adding "existing file " to my application.

    By accident I managed to "copy and paste" the entire form into my new , blank , form - all in QtDesigner.

    Small issue - no matter what I try the copy / paste DOES NOT maintaining the original layout . ( Break layout before "copy" is the worst "option" .)

    That in not big deal on few widgets form, and it is a good practice to rearrange the new form to suit my needs, BUT

    the question

    is there a way to "copy and paste" forms and MAINTAIN the layout?



  • @mrjj said in Copy and paste form does not maintain layout:

    Hi
    Just as a note.
    You can get around the "Not being able to copy to a form that has a layout" by
    dragging your widget to the left side Widget list.

    It creates an entry in the scratchPad.
    alt text
    (test in the picture)

    This can be as complex a widget as you like.
    You can then drag to insert into a layout like normal
    where it shows a small blue line to indicate the insertion point.

    dragging your widget to the left side Widget list. ???

    1. I do not have much luck
      should I have "Display Widgets " bar ??
      When I drag all I get is thick border "window" and that is it...
      Sometime it will "break " the layout.

    2. I also do not have "Scratchpad " bar.

    Do I need "more " that QtCreator version 3.5.1 / Qt 5.5.1 ?
    Or am I missing some option ?



  • @AnneRanch said in Copy and paste form does not maintain layout:

    By accident I managed to "copy and paste" the entire form into my new , blank , form - all in QtDesigner.

    Better keep it as 'an accident'.

    Short answer: I guess not.

    Because it copied all including widgets on this form separately (like copying multiple files from one directory to another on your PC) and just threw them on your new form, without any layout.

    Edit: I just tested around a bit. You can copy widgets with content and layout to another form with no layout, but you can not copy widgets with layout and content to another form, which has already a layout. (It pops up a warning, that the destination form has a layout set)


  • Lifetime Qt Champion

    Hi
    Just as a note.
    You can get around the "Not being able to copy to a form that has a layout" by
    dragging your widget to the left side Widget list.

    It creates an entry in the scratchPad.
    alt text
    (test in the picture)

    This can be as complex a widget as you like.
    You can then drag to insert into a layout like normal
    where it shows a small blue line to indicate the insertion point.



  • @mrjj said in Copy and paste form does not maintain layout:

    Hi
    Just as a note.
    You can get around the "Not being able to copy to a form that has a layout" by
    dragging your widget to the left side Widget list.

    It creates an entry in the scratchPad.
    alt text
    (test in the picture)

    This can be as complex a widget as you like.
    You can then drag to insert into a layout like normal
    where it shows a small blue line to indicate the insertion point.

    dragging your widget to the left side Widget list. ???

    1. I do not have much luck
      should I have "Display Widgets " bar ??
      When I drag all I get is thick border "window" and that is it...
      Sometime it will "break " the layout.

    2. I also do not have "Scratchpad " bar.

    Do I need "more " that QtCreator version 3.5.1 / Qt 5.5.1 ?
    Or am I missing some option ?



  • @AnneRanch

    @mrjj did this in QtDesigner, not QtCreator. His screenshot shows the widget bar on the left.

    To use this feature you'll need that menu bar to be visible. Maybe you have hidden it?!



  • @AnneRanch said in Copy and paste form does not maintain layout:

    @mrjj said in Copy and paste form does not maintain layout:

    Hi
    Just as a note.
    You can get around the "Not being able to copy to a form that has a layout" by
    dragging your widget to the left side Widget list.

    It creates an entry in the scratchPad.
    alt text
    (test in the picture)

    This can be as complex a widget as you like.
    You can then drag to insert into a layout like normal
    where it shows a small blue line to indicate the insertion point.

    dragging your widget to the left side Widget list. ???

    1. I do not have much luck
      should I have "Display Widgets " bar ??
      When I drag all I get is thick border "window" and that is it...
      Sometime it will "break " the layout.

    2. I also do not have "Scratchpad " bar.

    Do I need "more " that QtCreator version 3.5.1 / Qt 5.5.1 ?
    Or am I missing some option ?

    Never mid - fixed by closing he "widget categories " ( my invented term ) and now I have "Scratchpad " visible.

    This is why I like forum instead of "RTFM" some stuff is just buried way too deep.

    Appreciate the help.
    SOLVED



  • I need to reopen this thread.
    For fife of me I cannot figure out how to put the entire form into scratchpad.
    I keep picking individual widgets and that is not what I am after.

    So - how do I "drag and drop " the complete layout?


  • Lifetime Qt Champion

    @AnneRanch
    Hi
    I also tried that but it seems it won't allow dragging the top widget (the form)
    First I thought it was maybe due to being a MainWindow but didn't work for a QWidget based either.
    So I think its not possible simply from the fact you cant really drag the top one.



  • One more "gotcha"

    Dragging widget to scratchpad DELETES it from the form !


Log in to reply