Sizing a bottom dock widget with a TabWidget in the Main Window

  • I'm fairly new to QT and I'm trying to get a Bottom aligned DockWidget containing a TabWidget to size correctly with a central widget, where I would like to have the bottom DockWidget and TabWidget take up about 20% of the Main Window Space while the central widget should take up the rest. But the solutions I have tried have resulted in the central widget either getting a height of 0 or the Tab/DockWidget only getting a single small row at the bottom.

    My solution looks something like this:

                // Default size
                QRect rec = QApplication::desktop()->screenGeometry();
                resize(rec.width() * 0.8, rec.height() * 0.8);
                setCentralWidget(new QWidget(this));
                centralWidget()->resize(width(), height() * 0.8);
                centralWidget()->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
                m_bottom_container = new QDockWidget(this);
                m_botton_view_widget = new QTabWidget(m_bottom_container);
                m_botton_view_widget->resize(width(), height() * 0.2);
                m_botton_view_widget->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum));
                this->addDockWidget(Qt::BottomDockWidgetArea, m_bottom_container);

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.