Align buttons on the right side of QHBoxLayout.
Unsolved
General and Desktop
-
Hello!
I need to place buttons on the horizontal layout, I have several buttons, one I want to put on the left size of layout and the rest on the right side. So I do//your code here
lButtonLayout_ -> insertWidget(0, homeButton_); lButtonLayout_ -> insertWidget(1, backButton_); lButtonLayout_ -> insertWidget(2, addButton_); lButtonLayout_ -> insertWidget(3, removeButton_); lButtonLayout_ -> insertWidget(4, refreshButton_); lButtonLayout_ -> insertWidget(5, sendButton_, 1, Qt::AlignRight); rButtonLayout_ -> insertWidget(0, receiveButton_, 1); rButtonLayout_ -> insertWidget(1, rHomeButton_); rButtonLayout_ -> insertWidget(2, rBackButton_); rButtonLayout_ -> insertWidget(3, rAddButton_); rButtonLayout_ -> insertWidget(4, rRemoveButton_); rButtonLayout_ -> insertWidget(5, rRefreshButton_); buttonLayout_ -> insertLayout(0, lButtonLayout_); buttonLayout_ -> insertLayout(1, rButtonLayout_); on the left layout it is ok, but on the right layout the buttons which should be on the right corner are near the center, can you tell me what is wrong here? thank you.
-
Can you try a spacer to push them to your right
-
In the right layout all the items have the same default alignment, you never specified any specific alignment.
-
@tokafr said:
insertWidget
as @JohanSolo points out, you are not using any aligment which is extra paramter
http://doc.qt.io/qt-5.5/qboxlayout.html#insertWidget -
I do
insertWidget(1, rHomeButton_, 0, Qt::AlignRight);
and so on for all buttons
but it doesn't affect
1/5