Reputation: 73
In my program when a push button is pressed, I need the comboBox at the top of the verticalLayout to move down to the bottom so the 2nd comboBox is at the top. The comboBoxes have been created in Qt designer and I need this to be able to be done multiple times in one instance of the application. How could I go about doing this?
Upvotes: 0
Views: 353
Reputation: 243975
Widgets can not be moved freely within the layout, the layout manages the position and size of the widgets. The strategy to obtain that displacement is to remove the widget from the first position and reinsert it:
QLayoutItem *child;
// remove
if ((child = ui->verticalLayout->takeAt(0)) != 0) {
// insert
ui->verticalLayout->addItem(child);
}
You can find a complete example in the following link
Upvotes: 1