I have the following code where I put the button and text box in QGridLayout. PLease notices that I use columns 3 and 4 to place them.
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 need the text to be edited and the button only occupy 2/5 of the available horizontal space. That is why I placed them in the 3rd and 4th columns. How it does not work, how can I do it? Is there something like an empty space widget in Qt? I searched, but did not find it.
source
share