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();
}
相关推荐
laocooon5238578862 分钟前
一个C项目实现框架
c语言·算法
hweiyu0036 分钟前
Linux 命令:dd
linux
---学无止境---44 分钟前
i386 架构中断管理函数详解
linux·架构
cike_y44 分钟前
浅谈用docker搭建一个ctf镜像
运维·安全·网络安全·docker·容器·ctf
c#上位机1 小时前
halcon图像增强——图像取反
图像处理·算法·c#·halcon
zheyutao1 小时前
割点和桥
算法·图论
云和数据.ChenGuang1 小时前
运维工程师技术之openEuler 网卡基础查询指令
运维·中间件·mycat·运维工程师·运维技术
kkkkkkkkl241 小时前
Prometheus指标入门详解
linux·服务器
意疏1 小时前
不用云服务器也能跨设备转写!CapsWriter+cpolar 实现离线语音协作自由
运维·服务器
釉色清风1 小时前
在openEuler玩转Python
linux·开发语言·python