Results 1 to 16 of 16

Thread: Reparenting

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Reparenting

    Hello,

    How do you do reparenting within Designer?

    Is there an equivalent of the old UIM/X widget browser where you drag-and-drop a widget tree hiearchy into the new parent? Or, is there another way?

    Thanks,
    Ben

  2. The following user says thank you to brcain for this useful post:

    throwaway_acct (5th September 2020)

  3. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Reparenting

    What do you mean *re*parent with designer?
    Reparnting means changing a parent to an object, which suggests a dynamic process (i.e at run time).

  4. #3
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Reparenting

    By reparenting ... I mean changing the widget hiearchary ... moving an entire tree from a given node to another. For example, I might want to move (or copy) the children nodes of one parent widget to another. This might occur when wanting a set of widgets to be managed by some other widget.

  5. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Reparenting

    It could be that I still don't understand, but when you move a widget from one container widget to the other, the new container widget becomes the new parent of the moved/copied widget...
    But this you might know already, so I guess I just don't follow...

  6. #5
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Reparenting

    Quote Originally Posted by high_flyer View Post
    when you move a widget
    Moving is a different concept from changing parent. Perhaps that's the best way of explaining. I'm referring to changing the "ownship" of the widget ... changing which parent "contains" the child widget[s]. The reason I ask this is that sometimes it's very difficult to do this graphically ... with a move operation ... because the parent widgets may have very little screen space to actually drag the widgets into. Other tools I've used in the past have an editor that strictly shows the widget hierarchy. They also have an explicit parent field that can be edited ... which would also accomplish the reparenting.

  7. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Reparenting

    Moving is a different concept from changing parent.
    Not in designer.
    And it does makes sense - see below.
    But you can change the parent in code, which will also move the widget physically on to the new parent.
    I'm referring to changing the "ownship" of the widget ... changing which parent "contains" the child widget[s].
    Yes, we are talking of the same thing, but in this case, visually containing also means being the parent of the widget.
    because the parent widgets may have very little screen space to actually drag the widgets into
    Hmm... then somthing in the grphical design of your GUI must be wrong.
    What is the point of such a small container, that is so small you cant drag and drop in to it?
    It means you just see a small speck on the GUI...
    However,what you can try is, cut the widget you want to insert in to the small container, select the container, and then paste.

  8. #7
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Reparenting

    Quote Originally Posted by high_flyer View Post
    What is the point of such a small container, that is so small you cant drag and drop in to it?
    It means you just see a small speck on the GUI...
    It's only initially small ... while editing.

    An example ... when I create a grid layout widget and add the first child ... it resizes so that it's difficult to add the second widget graphically to the correct parent.

    Another example ... when I want to move widgets to a new parent that's not visible.

    Quote Originally Posted by high_flyer View Post
    However,what you can try is, cut the widget you want to insert in to the small container, select the container, and then paste.
    I'll try that (e.g. selecting in Object Inspector ... then pasting). I'm still on the learning curve.

  9. #8
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Reparenting

    Quote Originally Posted by brcain View Post
    I'll try that (e.g. selecting in Object Inspector ... then pasting). I'm still on the learning curve.
    This doesn't always work. It doesn't paste to the desired parent widget I have selected.

    I may just have to hand code the main window. The tool really needs more capabilities in this area.

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reparenting

    Quote Originally Posted by brcain View Post
    An example ... when I create a grid layout widget and add the first child ... it resizes so that it's difficult to add the second widget graphically to the correct parent.
    So first position widgets and then apply a layout, not the other way round.

    Another example ... when I want to move widgets to a new parent that's not visible.
    Are we talking design or run time? If the former, then all widgets are visible (provided you didn't shrink it manually, forgot to set sizeHints or layouts or stack some other widget on top of it - all of them being design flaws of your gui not the editor.

    I'll try that (e.g. selecting in Object Inspector ... then pasting). I'm still on the learning curve.
    Maybe you have a wrong approach here? Try to first build a hierarchy of objects you need, apply layouts to each hierarchy and only then position the groups as they should remain and as the last point, apply the layout to the form itself.

  11. #10
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Reparenting

    Quote Originally Posted by wysota
    So first position widgets and then apply a layout, not the other way round.
    That's probably it. I'm used to desigers that also support a top-down approach ... which can be useful for refactoring.

    Quote Originally Posted by wysota
    Maybe you have a wrong approach here? Try to first build a hierarchy of objects you need, apply layouts to each hierarchy and only then position the groups as they should remain and as the last point, apply the layout to the form itself.
    Does this approach work well with redesigning an interface?

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reparenting

    Quote Originally Posted by brcain View Post
    That's probably it. I'm used to desigers that also support a top-down approach ... which can be useful for refactoring.
    Designer supports it too, but if you have trouble using it, you can try a different approach (which is in my opinion more intuitive anyway).

    Does this approach work well with redesigning an interface?
    Sure, you can always break a layout and reposition your widgets.

    To be honest I'm not fond of statements "I have seen xxx do yyy. Why Designer/Qt does it differently?". I could probably ask you dozens of questions asking why xxx doesn't do zzz which is supported by Designer/Qt. Remember, nobody forces you to use either Designer or Qt. Most people like Qt also because it is easy to program using it. If you are used to bad habits, then maybe it is time to try to get rid of them and try a bit different approach, maybe you'll learn something new and if you do, you'll have the knowledge and experience to compare both approaches and choose one which fits you better. Not all that is expensive/commercial is well designed just because of being commercial, you should be aware of that when you enter a new environment. BTW, Qt is commercial too - all those statements apply to it as well. If you use Qt, use it because you like it, not because it is commercial/open source.

  13. #12
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Reparenting

    Quote Originally Posted by wysota
    To be honest I'm not fond of statements "I have seen xxx do yyy. Why Designer/Qt does it differently?".
    We all learn by comarison and contrast.
    Quote Originally Posted by wysota
    Remember, nobody forces you to use either Designer or Qt.
    I am "forcing" myself because I think it’s built upon a well designed framework. I do think there is room for improvement with Designer though. BTW, that's not intended as a personal insult to you ... just my humble opinion

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.