QDockWidget is covered under main window after setFloating(true)

时间:2018-09-18 20:34:46

标签: qt qt5

I want a dock widget to be floating at the beggining. So I add dock widget to the area and then setFloating(true). But the behaviour is that this dock widget is cover under main window (wont stayin on top)

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    auto* dock = new QDockWidget(this);
    auto* widget = new QWidget(dock);
    auto* layout = new QHBoxLayout();
    widget->setLayout(layout);
    dock->setWidget(widget);
    addDockWidget(Qt::RightDockWidgetArea, dock);
    dock->setFloating(true);


    layout->addWidget(new QPushButton("test", this));
}

Dock widget is visible in the right top corner, but when I drag the main window, dock widget hides under it. To fix it I have to drag dock widget to the dock area, then I set it floating again, and this widget is on top.

How to force QDockWidget to be floating and on top at the beginning?

Qt Version 5.11.1 on Ubuntu 18.04

0 个答案:

没有答案
相关问题