qt5 窗口启动居中显示

qt5 窗口启动居中显示

main.cpp里面修改

复制代码
#include "mainwindow.h"
#include <QApplication>
#include <QScreen>
#include <QDesktopWidget>


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    //w.show();


    //移动窗体到屏幕中央
    QRect rect = w.frameGeometry();
    QDesktopWidget desktop;
    QPoint centerPoint = desktop.availableGeometry().center();
    rect.moveCenter(centerPoint);
    w.move(rect.topLeft());

    w.show();

    return a.exec();
}
相关推荐
晨非辰2 小时前
Linux权限管理速成:umask掩码/file透视/粘滞位防护15分钟精通,掌握权限减法与安全协作模型
linux·运维·服务器·c++·人工智能·后端
夜颂春秋3 小时前
jmeter做压力测试
linux·运维·服务器·压力测试
lihui_cbdd6 小时前
AMBER 24 生产环境部署完全指南(5090可用)
linux·计算化学
TracyCoder1239 小时前
LeetCode Hot100(15/100)——54. 螺旋矩阵
算法·leetcode·矩阵
绾樘9 小时前
RHCE--基于Nginx的Web服务器配置
运维·服务器·nginx
生活很暖很治愈9 小时前
Linux基础开发工具
linux·服务器·git·vim
打工的小王10 小时前
docker(三)具体项目的部署
运维·docker·容器
u01092727110 小时前
C++中的策略模式变体
开发语言·c++·算法
2501_9418372610 小时前
停车场车辆检测与识别系统-YOLOv26算法改进与应用分析
算法·yolo
似霰10 小时前
Linux Shell 脚本编程——核心基础语法
linux·shell