tags:

views:

42

answers:

1

We have a window with several components in QDockWidgets. Ideally, we'd like to have all components dockable, but there is one component that will likely always be visible. So we made that the central widget.

However, this does not allow us to create a tabbed stack of dockable widgets (as you can create by e.g. calling tabifyDockWidget) containing this central widget. So, we tried to create a UI without a central widget, but with several QDockWidgets.

I cannot find any indication in the manual of QDockWidget or QMainWindow that this is a situation that isn't allowed. We create as much as possible in Qt Designer, and it seems to require that you have a central widget - as it shows by crashing after manually editing the XML.

The question is: is it legal to have a QMainWindow with only QDockWidgets and no central widget? Is Qt Designer just crashing because of a bug, or is it telling me that this is a bad idea and I need to stop doing this?

+1  A: 

Qt's documentation says that:

Note: Creating a main window without a central widget is not supported. You must have a central widget even if it is just a placeholder.

So you can just hide the empty central widget:

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->centralWidget->hide();
}
Roku