Qt empty space column in QGridLayout?
c++, layout, qt
Solution
Use void QGridLayout::setColumnStretch ( int column, int stretch ).
You can set `stretch = 1` for all columns. It will give the view you want.
Problem
I have the following code where I place a button and a text box in a `QGridLayout`. PLease notice that I use columns 3 and 4 for placing these. ``` QGridLayout *insAddPanel = new QGridLayout(); { QLineEdit* ledInstrumentName = new QLineEdit(); insAddPanel->addWidget(ledInstrumentName, 0, 3); QPushButton* btnAddInstrument = new QPushButton(); btnAddInstrument->setText("Add"); insAddPanel->addWidget(btnAddInstrument, 0, 4); } mainLayout->addLayout(insAddPanel); ...... ``` However when I run this, I get something like this: I wanted the text edit and the button to occupy only 2/5 of the available horizontal space. That is why I placed these in 3rd and 4th column. As this does not work, how do I get this done? Is there something like an empty space widget in Qt? I searched but did not find it.