Search code examples
qt5.5qdockwidget

Glimpse of QDockWidget in the middle of the screen when gets created


When I create a new QDockWidget

  myWidget = new MyDockWidget(this);
  MyMainWindow::instance()->addDockWidget(Qt::RightDockWidgetArea, mSettings);

I can see it in the middle of the screen. After that I can notice it is placed docked to the right. I'm running under debugger so understandably things are slow. Nevertheless end users might run on overbooked machines etc. Could I create the window docked already or hide it until it actually gets docked?

In constructor I have setupUi(this); for my MyDockWidget with following settings:

MyDockWidget->setFloating(true);
MyDockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
MyDockWidget->setAllowedAreas(Qt::RightDockWidgetArea);

So why it appears on center on start? How to fix this?

P.S. If I set dock widget parent to main window it appears undocked - why? What is correct parent? My current parent is mdi window.


Solution

  • Removed all features, left default like in Dock Widgets Example, and set parent to main window - works fine now.

    P.S. Set features DockWidgetFloatable | DockWidgetMovable manually, then same in Designer - works also - some weird bug. Solved.