Results 1 to 16 of 16

Thread: Reparenting

  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,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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

  14. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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
    We all learn by comarison and contrast.
    But you should try first and compare later, not the other way round.

    I am "forcing" myself because I think it’s built upon a well designed framework.
    Then stop forcing yourself and see if you like it.

    I do think there is room for improvement with Designer though.
    I didn't say there isn't. But I have used Designer for few years now, I've seen it develop and I know its flaws, so I can try to formulate opinions how to improve it. You are just starting to use it and you probably haven't seen half of its features yet.

    BTW, that's not intended as a personal insult to you ... just my humble opinion
    I didn't take it as an insult. I'm just expressing my thoughts too.

  15. #14
    Join Date
    Sep 2020
    Posts
    1
    Thanks
    1

    Default Re: Reparenting

    > 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

    Yikes - what a hostile and rude response to a completely valid user experience challenge. Other people like myself are encountering the same thing:

    * https://stackoverflow.com/questions/...e-right-parent
    * https://forum.qt.io/topic/4793/how-t...2-2-0-designer

  16. #15
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,689
    Thanks
    257
    Thanked 750 Times in 740 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Reparenting

    Yikes - what a hostile and rude response to a completely valid user experience challenge. Other people like myself are encountering the same thing:
    You realize you are complaining about a 14 year old post? Some of those people are still around and active in this forum, though.

    In Wysota's defense, while he can be brusque at times, his point is nonetheless valid: If you don't like the tool, don't use it. All Qt Designer is is a visible interface on top of an XML editor. The creators of Qt Designer chose a particular interaction style, which as the OP pointed out, is different from the one that he / she was used to when working in a different GUI environment. If you don't like Qt Designer, then you can build your GUI in C++ code without a ui file (which I often do for QMainWindow classes) or you can learn the ui XML syntax and hand code it (which I occasionally do when I want to tweak an interface or when I've screwed it up so badly in Designer that I have to fix it first before editing it again).

    There are several quirks to using Qt Designer that take time to understand and to work around. Over the 14 years since this original post, Qt Designer has improved so some of these interactions are not so frustrating as they once were. Some quirks remain, especially around the use of layouts. If you add certain widgets to a layout before others, it can be extremely difficult to add the new widgets because the first widget has expanded to take up all the space. On a high-res monitor, the line between being inside a layout and outside it can require extremely precise mouse movements to get the UI to show that you are inside the box. A layout that has been locked can't be modified and it can be difficult to select the layout itself and not one of the objects within it. And on and on. Over time and with enough use, you learn the idiosyncrasies and find workarounds.

    Prior to Qt5, there was no form layout, for example. It was added because the vertical, horizontal, and grid layouts didn't handle the layouts of forms where you might want editing widgets to align in a pleasing visual arrangement. 14 years ago, this didn't exist.

    It can be frustrating for a new user. And in the case of the OP's original question, the use of terminology ("reparenting" which has an entirely different meaning in the Qt world) contributed to the confusion about the question.

    Both of the links you posted involve these quirks with the use of layouts. In the second case, the poster is using a transparent (rectangular) widget with a non-rectangular image and trying to use existing (rectangular) layouts to look right, without a lot of success. As one of the responses said, he may have to develop his own layout manager that takes into account the irregular image.
    Last edited by d_stranz; 5th September 2020 at 21:55.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  17. #16
    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

    Quote Originally Posted by throwaway_acct View Post
    > 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

    Yikes - what a hostile and rude response to a completely valid user experience challenge. Other people like myself are encountering the same thing:

    * https://stackoverflow.com/questions/...e-right-parent
    * https://forum.qt.io/topic/4793/how-t...2-2-0-designer
    I fully second d_stranz's answer.'
    And he actually took much more time and effort to answer your post then I would be inclined to.

    I don't see what is "hostile" about the answer you quoted.
    The first part is a dry fact - no one, indeed, is forcing anyone to use any tool, and the second it a good advice.

    And I know wysota personally, he talks straight, but not offensive - if you see offence in this text, it is of your own making - as the saying goes: "beauty is the eye of the beholder" - this is true for anything really.
    As long as no foul or clearly abusive language is used, I see no issue.
    If you feel offended from a post that is not violating the forums rules, simply ignore it (and without offending: if you find yourself being offended often in this manner, it might be a good idea to look inwards to see why you are quick to interpret posts as offending so often, again, *if*, and this sentence was not meant as a jab as as a friendly suggestion).

    Oh, and don't speak in the name of "other people" unless they actually told you so - we didn't get other complaints so far (on this subject).
    If someone else has encountered abusive comments, they can, and should use the report button as you did - so if someone does contact you about it, please tell them to report.

    P.S
    In his last comment wysota wrote he following:
    I didn't take it as an insult. I'm just expressing my thoughts too.
    I think this should make his intention clear to NOT be rude.

    Cheers.
    Last edited by high_flyer; 5th September 2020 at 19:47.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

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.