PDA

View Full Version : Reparenting



brcain
19th September 2006, 15:41
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

high_flyer
19th September 2006, 15:49
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).

brcain
19th September 2006, 15:55
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.

high_flyer
19th September 2006, 16:03
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...

brcain
19th September 2006, 16:10
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.

high_flyer
19th September 2006, 16:20
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.

brcain
19th September 2006, 16:57
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.



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.

brcain
19th September 2006, 18:00
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.

wysota
19th September 2006, 18:01
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.

brcain
19th September 2006, 18:10
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.



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?

wysota
19th September 2006, 18:19
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.

brcain
19th September 2006, 20:30
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.

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 ;)

wysota
19th September 2006, 22:32
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.

throwaway_acct
5th September 2020, 03:28
> 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/3763893/qt-designer-difficulty-placing-widgets-in-the-right-parent
* https://forum.qt.io/topic/4793/how-to-change-a-widget-ancestor-in-qt-creator-2-2-0-designer

d_stranz
5th September 2020, 17:45
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.

high_flyer
5th September 2020, 19:41
> 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/3763893/qt-designer-difficulty-placing-widgets-in-the-right-parent
* https://forum.qt.io/topic/4793/how-to-change-a-widget-ancestor-in-qt-creator-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 (https://www.qtcentre.org/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.