[SOLVED] Problem with mainLayout of Dialog.
-
wrote on 7 Sept 2011, 17:06 last edited by
I have a problem with the mainLayout. I have this:
@ optionsGroupBox = new QGroupBox();
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:
!http://img683.imageshack.us/img683/4044/screenshotsaywhat.png(screen)!
but i want it look like:
!http://img836.imageshack.us/img836/7202/screenshot1flw.png(screen2)!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:
!http://img11.imageshack.us/img11/4044/screenshotsaywhat.png(screen3)! -
wrote on 7 Sept 2011, 17:29 last edited by
[quote author="Leon" date="1315415173"]I have a problem with the mainLayout. I have this:
@ optionsGroupBox = new QGroupBox();
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 QVBoxLayout lineAndBrowseLayout = new QVBoxLayout; 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);@
[/quote]
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. -
wrote on 7 Sept 2011, 18:33 last edited by
There is a QGridLayout::addWidget() overload which takes a rowSpan and a columnSpan too.
@
optionsGroupBoxLayout->addWidget(ui->comboBox, 0,1,1,2);
optionsGroupBoxLayout->addWidget(ui->lineEdit, 1,1,1,2);
@
Will do the trick. -
wrote on 7 Sept 2011, 19:52 last edited by
k the first answer is ok! :D
Just not -QVBoxLayout- lineAndBrowseLayout = new -QVBoxLayout-;
but lineAndBrowseLayout = new QHBoxLayout
will do what i want.. thanks ;) -
wrote on 8 Sept 2011, 14:01 last edited by
I don't know why, but I always do that! It's like a mini brain rebellion over which I have no control :D
-
wrote on 8 Sept 2011, 14:24 last edited by
On a side-note. The word is "Browse", not "Browze". You also might want to check if you really want to say "Nami".
1/6