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();
}
相关推荐
2601_949221032 小时前
Splashtop赋能企业级远程办公全场景安全连接成选型优选
运维·人工智能·安全
七度黑光3 小时前
用 openclaw 给故障复盘打分:质量审核自动化实践
运维·服务器·前端·数据库·自动化
123过去3 小时前
nfc-list使用教程
linux·网络·测试工具·安全
阿豪学编程3 小时前
LeetCode724.:寻找数组的中心下标
算法·leetcode
墨韵流芳4 小时前
CCF-CSP第41次认证第三题——进程通信
c++·人工智能·算法·机器学习·csp·ccf
last demo4 小时前
mysql
运维·数据库·mysql·oracle
灰阳阳4 小时前
Dockerfile实践-构建Nginx镜像
运维·nginx·docker·dockerfile
csdn_aspnet4 小时前
C# 求n边凸多边形的对角线数量(Find number of diagonals in n sided convex polygon)
开发语言·算法·c#
凌波粒5 小时前
LeetCode--349.两个数组的交集(哈希表)
java·算法·leetcode·散列表
evo-master5 小时前
网络故障排除方法
linux·服务器·网络