bug of QMdiArea showing scrollbar ?
-
Hei, guys.
I have a MainWindow project from 'new project wizard'.
VS2019+5.15.2+Win7
Here is my code:MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); m_mdiArea = new QMdiArea(this); m_mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); m_mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setCentralWidget(m_mdiArea); QMenu *mu = new QMenu("test"); QAction *a = new QAction("add widget1"); mu->addAction(a); connect(a,&QAction::triggered,this,[&](){ auto *w1 = new QWidget; auto *b1 = new QPushButton("btn1-1"); auto *b2 = new QPushButton("btn1-2"); auto *vlay = new QVBoxLayout; auto *sw = new QMdiSubWindow; vlay->addWidget(b1); vlay->addSpacerItem(new QSpacerItem(20,40,QSizePolicy::Minimum,QSizePolicy::Expanding)); vlay->addWidget(b2); w1->setLayout(vlay); w1->resize(500,400); w1->setMinimumHeight(400); sw->setWidget(w1); sw->resize(w1->size()); m_mdiArea->addSubWindow(sw); w1->show(); }); a = new QAction("add widget2"); mu->addAction(a); connect(a,&QAction::triggered,this,[&](){ QWidget *w2 = new QWidget; auto *b1 = new QPushButton("btn2-1"); auto *b2 = new QPushButton("btn2-2"); auto *vlay = new QVBoxLayout; QMdiSubWindow *sw = new QMdiSubWindow; vlay->addWidget(b1); vlay->addSpacerItem(new QSpacerItem(20,40,QSizePolicy::Minimum,QSizePolicy::Expanding)); vlay->addWidget(b2); w2->setLayout(vlay); w2->resize(500,400); w2->setMinimumHeight(400); sw->setWidget(w2); sw->resize(w2->size()); m_mdiArea->addSubWindow(sw); w2->show(); }); menuBar()->addMenu(mu); resize(650,380); }
when add a widget, not showing horizon scrollbar from mdiarea(Step1), then click subwindow to show max,the vertical scrollbar shows fine(Step3).
but, if add a widget, and showing horizon scrllbar from mdiarea(Step1), then click subwindow to show max,the vertical scrollbar Will NOT show anymore(Step3).here is the picture, vbar shows fine:
vbar will not show anymore if we have horizon bar on start:
why? any tips will be appreciated.
-
I can confirm this issue and think it's fixable. For now set the minimum size to sw too.
-
Created a bug report: https://bugreports.qt.io/browse/QTBUG-100494
-
Merged, will be fixed in Qt6.4.