MainWindow's child DockWidget disappears if I call setFloating(true)
I've been having some trouble with the QDockWidget class. I've set my QDockWidget instance as a child of my MainWindow, but calling setFloating(true) on the QDockWidget causes it to disappear when I run my program. See below: if I run the code as presented, the dock widget appears with the example strings I added. in the top left of my main window. If I uncomment the line containing setFloating(true), instead I get a completely blank main window. But from what I see in the documentation, dock widgets are floating by default, so I don't think setFloating(true) should even have an effect. Am I missing something, or perhaps am I misunderstanding the meaning of "floating"?
I am using Qt 5.11.1 on Ubuntu 18.04.
Code:
MainWindow
::MainWindow(QWidget *parent
) , ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_docker->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
//m_docker->setFloating(true);
<< "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton"
<< "Jane Doe, Memorabilia, 23 Watersedge, Beaton"
<< "Tammy Shea, Tiblanka, 38 Sea Views, Carlton"
<< "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal"
<< "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston"
<< "Sally Hobart, Tiroli Tea, 67 Long River, Fedula");
m_docker->setWidget(example_list);
}
Re: MainWindow's child DockWidget disappears if I call setFloating(true)
Quote:
I get a completely blank main window
According to this code, you have no central widget, so the inside of the main window -should- be blank.
Is your floating dock widget behind the main window? (Move the main window...)
What happens if you float the dock widget and call its show() method manually? Could be that docking it forces it to be shown when the main window is shown, but not if it starts out floating.