[SOLVED] addWidget determinded
-
Hello
If I add a QWidget in QHBoxLayout. Then it is always added at the end of all other already added QWidgets. Is there a possibility to add a QWidget to a determinded positon, e.g. at the second position?
I'm aware of the possibility to first remove all other QWidgets until the desired position and then add them again after. But this not very flexible if I don't know how much widgets I have after the second position.
Thx for help.
-
Sure. Use the insertWidget method instead of the addWidget method.
-
Hmmm, sometimes Google isn't really my friend! : )
-
Google is not great for Qt documentation. But the documentation itself is pretty good in general. This is really easy to find. You go to QVBoxLayout, find it pretty much empty of methods, and open op the docs for the super class QBoxLayout instead. A quick glance on that documentation reveals that you have add* methods as well as insert* methods. A pattern that is also available in may other classes dealing with lists or other ordered collections...
-
Jap, that one I'm using too. Normally I should have found this. Don't know why I haven't searched for other methods, I was too focused on the addWidget method. Could be friday afternoon. : )
Anyway, I'm very happy with the Qt Community here, thank you very much for this quick help here anytime.