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.

Qt Code:
  1. MainWindow::MainWindow(QWidget *parent)
  2. : QMainWindow(parent)
  3. , ui(new Ui::MainWindow)
  4. {
  5. ui->setupUi(this);
  6. m_docker = new QDockWidget(this);
  8. m_docker->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
  9. //m_docker->setFloating(true);
  11. QListWidget* example_list = new QListWidget(m_docker);
  12. example_list->addItems(QStringList()
  13. << "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton"
  14. << "Jane Doe, Memorabilia, 23 Watersedge, Beaton"
  15. << "Tammy Shea, Tiblanka, 38 Sea Views, Carlton"
  16. << "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal"
  17. << "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston"
  18. << "Sally Hobart, Tiroli Tea, 67 Long River, Fedula");
  19. m_docker->setWidget(example_list);
  21. }
To copy to clipboard, switch view to plain text mode