PDA

View Full Version : arranging objects in splitter widget



bigbill
13th December 2010, 11:38
hello, I want to add some pushButtons, labels and lineEdit (in other words a form!)in the chart example.
How can I do that?

Tried with addWidget

splitter->addWidget(table);
splitter->addWidget(pieChart);
.
.
splitter->addWidget(mesLabel1);
splitter->addWidget(inputBox1);

... but the default layout was terrible.

also tried to create a layout and add it in the splitter
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(mesLabel1, 0, 0);
mainLayout->addWidget(inputBox1, 0, 1);
.
.
but the addWidget() accepts only QWidget parameter

So, how I can create a layout and add it in an (existing) QSplitter widget?

hackerNovitiate
13th December 2010, 12:20
I haven't used QSplitters myself, but the documentation seems to suggest that you can't add a layout to a QSplitter. May I suggest placing multiple QSplitters in a layout? Or maybe using a QFormLayout instead?

Edit: Another possible (but bulky) approach: Make a custom widget (e.g. call it BigWidget) that contains a label and input box in your desired layout. Then add a BigWidget into the QSplitter.

bigbill
13th December 2010, 12:33
Thanks , I have found a solution
http://www.qtcentre.org/threads/16856-QSplitter-multiple-layouts-how