PDA

View Full Version : Layout messing up



therealjag
9th April 2006, 22:55
hey there i have a QHBox of my main widget, QHBox of buttons and then i have a QHBox of a QStatusBar but when i add them to my main layout the QStatusBar widget ends up taking half the space on my tab dialog....why is this happening? heres the code below and i attached the image of how it looks now...



sortingBox = new SortingBox;
QVBoxLayout *mainLayout = new QVBoxLayout;


QHBoxLayout * buttonsLayout = new QHBoxLayout;
QHBoxLayout * messageLayout = new QHBoxLayout;
QGridLayout * gridLayout = new QGridLayout;


QPushButton * clearButton = new QPushButton("Clear");
connect(clearButton, SIGNAL(clicked()), sortingBox, SLOT(clear()));clearButton->setShortcut(tr("Ctrl+R"));
buttonsLayout->addWidget(clearButton);

QPushButton * clearLinks = new QPushButton("Clear Links");
connect(clearLinks, SIGNAL(clicked()), sortingBox, SLOT(clearLinks()));
buttonsLayout->addWidget(clearLinks);

QPushButton * clearLastLink = new QPushButton("Clear Last Link");
connect(clearLastLink, SIGNAL(clicked()), sortingBox, SLOT(clearLastLink()));
buttonsLayout->addWidget(clearLastLink);

QPushButton * dijkstra = new QPushButton("Calc Shortest Path");
connect(dijkstra, SIGNAL(clicked()), sortingBox, SLOT(startDijkstra()));
buttonsLayout->addWidget(dijkstra);

QStatusBar * sbar = new QStatusBar();
connect(sortingBox, SIGNAL(showStatus(QString)), sbar, SLOT(showMessage(QString)));
messageLayout->addWidget(sbar);

//gridLayout->addLayout(buttonsLayout, 0, 0);
//gridLayout->addWidget(sbar, 1, 0, 1, 0);
mainLayout->addWidget(sortingBox);
mainLayout->addLayout(buttonsLayout);
mainLayout->addWidget(sbar);
setLayout(mainLayout);

jpn
10th April 2006, 07:40
Supposedly the "sorting box" should take the available space, instead?
Change sorting box's vertical size policy to QSizePolicy::Expanding or QSizePolicy::MinimumExpanding.