PDA

View Full Version : Programmatically Dock



venkateshhegde
13th February 2011, 14:31
Hello Everybody,

I need to programmatic-ally dock windows like this:
5944

But QT Designer does it like this:

5942

How do i programmatically do the desired behavior?

Qt Only allows the mainWindow to call
MainWindow->addDockWidget(static_cast<Qt::DockWidgetArea>(1), B);
and
MainWindow->addDockWidget(static_cast<Qt::DockWidgetArea>(1), A);

I need to get control of how the two dock widgets are laid out.

My Goal is to have complex layout like this:
5945

The idea is that once the user does his thing, I need to save and recreate this layout.

Any help is appreciated.


--
Regards,
ven.

wysota
13th February 2011, 23:27
Set QMainWindow::dockNestingEnabled to false to prevent nesting docks. I'm afraid your desired layout will be difficult to obtain. You need to force the size hint of the first dock to be so large that no other docs can be nested with it. Of course this will fail if user resizes the window...

venkateshhegde
13th February 2011, 23:40
How is it that the User Action is yielding the result but programmatically its not possible?
I should be able to dock different windows in a single area (Left as shown above) like this:

______
__|2
1_|___
__|3
__|___

wysota
14th February 2011, 00:00
I didn't say it was not possible. I said the dock has to have proper size. It could be that you can manipulate the value of the property I pointed you to between adding different docs, maybe you'll get your configuration this way (try disabling dock nesting before adding the second dock and enabling it back again before adding the last one).

venkateshhegde
14th February 2011, 00:35
Answer Gotcha! These APIs help.. They are like Splitter Apis... I was able to get my results!!!!!
Thaank you for the help!



void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget);
void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget,
Qt::Orientation orientation);
void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget,
Qt::Orientation orientation);
void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
QList<QDockWidget*> tabifiedDockWidgets(QDockWidget *dockwidget) const;
void removeDockWidget(QDockWidget *dockwidget);
bool restoreDockWidget(QDockWidget *dockwidget);