I'm developing a file dialog to import file in my application and I want to have an additional QComboBox
with a list of formats between File names
edit and File of types
filter combo box, like this:
I've managed to add QComboBox
under filters like this:
using this code:
QGridLayout * layout = qobject_cast <QGridLayout *>(dialog->layout());
QLabel * labelFormat = new QLabel(tr("Format"), dialog);
layout->addWidget(labelFormat, 4, 0);
QComboBox * comboBoxFormat = new QComboBox(dialog);
layout->addWidget(comboBoxFormat, 4, 1);
But I need to swap the last two rows of this grid layout. I've tried something like this to swap rows:
QWidget * w0 = layout->itemAtPosition(3, 0)->widget();
QWidget * w1 = layout->itemAtPosition(3, 1)->widget();
QWidget * w2 = layout->itemAtPosition(3, 2)->widget();
QLabel * labelFormat = new QLabel(tr("Format"), dialog);
layout->addWidget(labelFormat, 3, 0);
QComboBox * comboBoxFormat = new QComboBox(dialog);
layout->addWidget(comboBoxFormat, 3, 1);
layout->replaceWidget(w0, labelFormat);
layout->replaceWidget(w1, comboBoxFormat);
layout->addWidget(w0, 4, 0);
layout->addWidget(w1, 4, 1);
layout->addWidget(w2, 4, 2);
But I got the wrong widgets position:
How can I achieve the widget positioning from the first screenshot?