qt - QMainWindow: size management of central widget and dock widgets -
i want mainwindow keep approximate ratio of dock widget sizes , central widget size, when window's size changed. i've written simplest mainwindow central widget , 6 dock widgets:
#include <qplaintextedit> #include <qdockwidget> #include "mainwindow.h" mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent) { this->setgeometry(20, 20, 600, 600); this->setcentralwidget( new qplaintextedit("central", this) ); qdockwidget *p_dw; (int = 0; < 6; ++i){ p_dw = new qdockwidget("dock " + qstring::number(i)); p_dw->setwidget( new qplaintextedit("dock " + qstring::number(i), this) ); qt::dockwidgetarea area; switch (i){ case 0: case 1: area = qt::topdockwidgetarea; break; case 2: area = qt::rightdockwidgetarea; break; case 3: case 4: area = qt::bottomdockwidgetarea; break; default: area = qt::leftdockwidgetarea; break; } adddockwidget(area, p_dw); } } mainwindow::~mainwindow() { }
when started, looks follows:
i can shrink it:
and expand back, , after expanded, looks @ first screenshot. fine.
the problem if user "touches" central widget bounds (i mean, changes central widget size manually, ever little bit), main window changes policy dramatically: after user touches central widget, shrinks window, , expands back, dockwidgets have minimum sizes:
the question is, how prevent behavior? or, more generally, how can influence on size policy of qmainwindow
? can't find documentation behaviour i've explained above.
Comments
Post a Comment