QT:主页面全屏显示(根据显示屏分辨率调整主页面尺寸)

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);
}

猜你喜欢

转载自blog.csdn.net/sazass/article/details/113105691