PDA

View Full Version : QDockWidget problem..



jajdoo
16th July 2010, 20:54
trying to create something of this sort:
http://www.youtube.com/watch?v=GvGLzMXiaM0

i made a blank main window, and started adding QDockWidgets to it
for(int i = 0; i<4; i++)
{
QDockWidget* qa = new QDockWidget;
qa->setWidget(new CodeTextEdit);
qa->setAllowedAreas(Qt::AllDockWidgetAreas);
addDockWidget(Qt::TopDockWidgetArea, qa);
}

the problem is that i either get QDockWidgets that dock horizontally or vertically...
what am i doing wrong?

norobro
16th July 2010, 23:33
The code for that app is in "demos/mainwindow" or in the docs here (http://doc.trolltech.com/4.6/demos-mainwindow.html).

One way to do what you want to do is make a list of available dock areas and iterate through it:
QList <Qt::DockWidgetArea> dockAreaList;
dockAreaList << Qt::TopDockWidgetArea << Qt::RightDockWidgetArea << Qt::BottomDockWidgetArea << Qt::LeftDockWidgetArea;

Then in your for loop:
addDockWidget(dockAreaList[i], qa);

jajdoo
17th July 2010, 06:34
when i try the code you suggested and nest them all together, i get only horizontal or vertical when i try to separate them ..
I'll take a look at the example.. see what i can dig up..

is there something i need to set up to allow them to dock anywhere? (other than set allowed areas, that didn't really help)

jajdoo
17th July 2010, 10:28
well; hacked my way there...
used setCentralWidget so thatthey could dock all around it