[SOLVED] Problem with mainLayout of Dialog.
I have a problem with the mainLayout. I have this:
- optionsGroupBoxLayout = new QGridLayout;
- optionsGroupBoxLayout->addWidget(ui->label, 0,0);
- optionsGroupBoxLayout->addWidget(ui->comboBox, 0,1);
- optionsGroupBoxLayout->addWidget(ui->label_2, 1,0);
- optionsGroupBoxLayout->addWidget(ui->lineEdit, 1,1);
- optionsGroupBoxLayout->addWidget(ui->label_3, 2,0);
- optionsGroupBoxLayout->addWidget(ui->lineEdit_2, 2,1);
- optionsGroupBoxLayout->addWidget(ui->pushButton_3, 2,2);
- optionsGroupBox->setLayout(optionsGroupBoxLayout);
- buttonsLayout = new QHBoxLayout;
- buttonsLayout->addStretch();
- buttonsLayout->addWidget(ui->pushButton_2);
- buttonsLayout->addWidget(ui->pushButton);
- mainLayout = new QVBoxLayout;
- mainLayout->addWidget(optionsGroupBox);
- mainLayout->addLayout(buttonsLayout);
- setLayout(mainLayout);
and it looks like:

but i want it look like:

So the question
What about the space up from the button Browze.. How can it be covered from the above linedit? ( See second screenshot )
Thanks for any answers :)
P.S When i say the space up from the button Browze i mean:

5 replies
I have a problem with the mainLayout. I have this:The bit I added above should do the trick. Note, however, that the space available to position (2,1) in the grid (where we’re adding the new layout) will be divided equally between the line edit and the Browse button, i.e. they’ll be the same size. You may have to play around with constraints a bit to get your ratio of QLineEdit::QPushButton space usage just right.
optionsGroupBoxLayout = new QGridLayout; optionsGroupBoxLayout->addWidget(ui->label, 0,0); optionsGroupBoxLayout->addWidget(ui->comboBox, 0,1); optionsGroupBoxLayout->addWidget(ui->label_2, 1,0); optionsGroupBoxLayout->addWidget(ui->lineEdit, 1,1); optionsGroupBoxLayout->addWidget(ui->label_3, 2,0); //add an additional layout for the Browse button and second line edit lineAndBrowseLayout->addWidget(ui->lineEdit_2); lineAndBrowseLayout->addWidget(ui->pushButton_3); optionsGroupBoxLayout->addLayout(lineAndBrowseLayout, 2,1);* optionsGroupBox->setLayout(optionsGroupBoxLayout); buttonsLayout = new QHBoxLayout; buttonsLayout->addStretch(); buttonsLayout->addWidget(ui->pushButton_2); buttonsLayout->addWidget(ui->pushButton); mainLayout = new QVBoxLayout; mainLayout->addWidget(optionsGroupBox); mainLayout->addLayout(buttonsLayout); setLayout(mainLayout);
You must log in to post a reply. Not a member yet? Register here!




