vs QT Use QGuiApplication::screens报错

严重性 代码 说明 项目 文件 行 禁止显示状态 错误 C4996 'QDesktopWidget::availableGeometry': Use QGuiApplication::screens(

解决方法:

QRect rect = w.frameGeometry();

QDesktopWidget desktop;

// QPoint centerPoint = desktop.availableGeometry().center();

// QPoint centerPoint = QGuiApplication::screens;

QPoint centerPoint= QGuiApplication::primaryScreen()->availableGeometry().center();

rect.moveCenter(centerPoint);

w.move(rect.topLeft());

即可居中显示咯

相关推荐
郝学胜-神的一滴32 分钟前
Effective STL 条款 07:指针容器销毁前先删除
开发语言·c++·vscode·leetcode·rpc·visual studio
CoderYanger43 分钟前
A.每日一题:2243. 计算字符串的数字和
java·开发语言·程序人生·leetcode·面试·蓝桥杯·学习方法
摇滚侠2 小时前
《On Java 中文版 基础卷》阅读笔记 接口 19
java·开发语言·笔记
吃我一窝jio3 小时前
Java多线程核心知识点梳理
java·开发语言·笔记
Lucas. Wáng3 小时前
Qt学习之旅
c++·qt
geovindu4 小时前
rust: Timing Functions Pattern
开发语言·后端·设计模式·rust·计时函数模式·性能分析型模式
geovindu4 小时前
python:Lasso
开发语言·后端·python·算法
多加点辣也没关系5 小时前
JavaScript|第42章:安全与最佳实践
开发语言·javascript·安全
3095566665 小时前
股票数据落库前的去重与主键设计:一次 SQLite 写入实录
java·开发语言·jvm·数据库·redis·python·sqlite
利威尔xu6 小时前
2026-11-19-Go反射为什么慢面试
开发语言·面试·golang