Solved Insert widgets from the left in an horizontal layout
-
Hello!
I am doing a task in which I have to insert widgets in an horizontal layout. How can I do to insert them by the left?
Thank you very much!
-
@ivanicy
https://doc.qt.io/qt-5/qboxlayout.html#insertWidget.QBoxLayout::insertWidget(int index, QWidget *widget)
inserts (at the left) if you pass e.g.0
forindex
. -
@JonB Yes but, when I want to insert another widget... if I do that, it will overlay it
-
@ivanicy
No it won't, that's why the method is insert widget, and docs say it inserts! :) There is no "replacing/overlaying". Why don't you try it?As a different approach, there is also https://doc.qt.io/qt-5/qboxlayout.html#Direction-enum,
QBoxLayout::RightToLeft
, which would let you useaddWidget()
and put it at the left instead of the normal right. But it's really the same sort of thing. -
@JonB Oh, sorry man. I tried it yesterday with addWidget method. But with insertWidget works fine!! Thank you very much!
-
@ivanicy
:) EvenaddWidget()
won't "replace/overlay",addWidget()
is onlyinsertWidget(-1)
, they both "insert" at the end.