@@ -77,6 +77,15 @@ MainWindow::MainWindow(QWidget *parent)
7777 ui->setupUi (this );
7878 ui->menubar ->show ();
7979
80+ // !\~chinese 当有停泊条且视图类型改变时,使用一个容器窗口,防止视图窗口大小发生改变。
81+ // !\~english
82+ // ! When there are docking bars and the view type changes,
83+ // ! use a container window to prevent the view window size from changing.
84+ QWidget* pContain = new QWidget (this );
85+ if (pContain) {
86+ setCentralWidget (pContain);
87+ }
88+
8089 ui->actionKeyboard ->setVisible (false );
8190#if ANDROID
8291 bool bVisible = (nullptr != QGuiApplication::inputMethod ());
@@ -569,7 +578,26 @@ void MainWindow::SetView(CView* pView)
569578 m_pView->disconnect ();
570579
571580 m_pView = pView;
572- setCentralWidget (m_pView);
581+ auto * pContain = centralWidget ();
582+ if (!pContain) return ;
583+ auto * pOldLayout = pContain->layout ();
584+ if (pOldLayout) {
585+ pContain->setLayout (nullptr );
586+ // Remove all child controls from the layout
587+ QLayoutItem* item;
588+ while ((item = pOldLayout->takeAt (0 )) != nullptr ) {
589+ if (item->widget ()) {
590+ item->widget ()->deleteLater ();
591+ }
592+ delete item;
593+ }
594+ delete pOldLayout;
595+ }
596+ auto * pLayout = new QVBoxLayout (pContain);
597+ if (pLayout) {
598+ pContain->setLayout (pLayout);
599+ pLayout->addWidget (m_pView);
600+ }
573601
574602 bool check = false ;
575603 // m_pView->setFocusPolicy(Qt::NoFocus);
@@ -657,10 +685,9 @@ void MainWindow::on_actionUpdate_triggered()
657685
658686void MainWindow::on_actionFull_screen_F_triggered ()
659687{
660- CView* pView = qobject_cast<CView*>(this ->centralWidget ());
661- if (pView)
688+ if (m_pView)
662689 {
663- pView ->SetFullScreen (!isFullScreen ());
690+ m_pView ->SetFullScreen (!isFullScreen ());
664691 }
665692
666693 if (isFullScreen ())
0 commit comments