QT: Full screen display of the main page (adjust the size of the main page according to the display resolution)

mainwindow.h

#include <QDesktopWidget>
#include <QMainWindow>

mainwindow.cpp

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
	QDesktopWidget dw;
    int w=dw.width()*1;//设置宽度为桌面的宽度的比例为1
    int h=dw.height()*1; // 设置高度为桌面的高度的比例为1
    this->setFixedSize(w,h);
}

Guess you like

Origin blog.csdn.net/sazass/article/details/113105691