PDA

View Full Version : QDockWidget floating at the beginning



Caius Aérobus
2nd March 2011, 14:15
I want to have a dock floating by default, I mean floating at application launch time, letting the user the possibility to dock it in any area, rather than having it docked at the beginning and offering the possibility to make it floating.
If I write:

QDockWidget *dock = new QDockWidget;
dock->setFloating(true);
dock->setWidget(w);
the widget does not appear.
If I write:

QDockWidget *dock = new QDockWidget;
dock->setFloating(true);
dock->setWidget(w);
dock->show();
it appears but can no longer be grabbed and moved anywhere.
Any idea?

Added after 34 minutes:

Solution: it is necessary to dock the widget first and then to undock it by making it floating:

QDockWidget *dock = new QDockWidget;
dock->setWidget(w);
this->addDockWidget(Qt::TopDockWidgetArea, dock);
dock->setFloating(true);