首页 > 解决方案 > 如何在不设置为最大化的情况下最大化尺寸?

问题描述

使用 QT5 在 Win10 上工作。

showMaximized可以使窗口最大化。但是,如果双击标题栏,它将调整大小。所以我想将窗口设置得尽可能大(不是全屏,还是要 Windows 任务栏),并将其设置为固定,这样就禁用了双击。我应该如何获得最大尺寸?

标签: c++qtqt5qmainwindow

解决方案


您可以确定当前屏幕的大小

int  screen_height = QApplication::desktop()->screenGeometry().height();
int  screen_width = QApplication::desktop()->screenGeometry().width();

你可以做这样的事情

Widget* w = new Widget;
int  screen_height = QApplication::desktop()->screenGeometry().height();
int  screen_width = QApplication::desktop()->screenGeometry().width();
w->setMinimumSize(screen_width-10, screen_height-screen_height/12);
w->showMaximized();

推荐阅读