[Solved] Layout issue
We are creating a tabbed dialog. I am adding a code snippet, so it will be easier for you to understand.
@MyDialog::MyDialog(QWidget parent): QDialog(parent)
MainIFaceTab = new QTabWidget(this);
MainIFaceTab->addTab(new AddUser,"Add User");
QVBoxLayout qvbl=new QVBoxLayout;
QHBoxLayout *qhbl=new QHBoxLayout();
connect(MainIFaceTab, SIGNAL(currentChanged(int)), SLOT(TabChange(int)));
The problem here is that, we want the button at the bottom right corner of the dialog. But when this dialog is displayed, the buttons are shown apart one at the right and at the middle. (Properly saying if we split the dialog vertically in to two, the two buttons are at the right of each half).
How are we doing wrong, how can we solve this?
It is <code>addStretch()</code>, not <code>stretch()</code> (which just returns the stretch factor of a given item).
btnClose = new QPushButton("&Close", this);
btnAdd = new QPushButton("&Add", this);
qhbl->addWidget(btnClose, 0, Qt::AlignRight);
qhbl->addWidget(btnAdd, 0, Qt::AlignRight);
You should consider using QDialogButtonBox instead, which presents buttons in a layout that is appropriate to the current widget style.
Thanks Lukas Geyer. QDialogButtonBox solved our problem. How can I mark this thread as solved?
You need to edit your first post and then add [Solved] to the title.
There is unfortunately no automatism to mark posts as solved "yet":http://qt-project.org/forums/viewforum/46/, so just prepend the inital post title with [Solved], as Sam already suggested.