徐州建设工程交易网站质量监督,新电商平台,手机网站支付,网络游戏开发平台若该文为原创文章#xff0c;转载请注明原文出处 本文章博客地址#xff1a;https://hpzwl.blog.csdn.net/article/details/140036861
长沙红胖子Qt#xff08;长沙创微智科#xff09;博文大全#xff1a;开发技术集合#xff08;包含Qt实用技术、树莓派、三维、OpenCV…若该文为原创文章转载请注明原文出处 本文章博客地址https://hpzwl.blog.csdn.net/article/details/140036861
长沙红胖子Qt长沙创微智科博文大全开发技术集合包含Qt实用技术、树莓派、三维、OpenCV、OpenGL、ffmpeg、OSG、单片机、软硬结合等等持续更新中…
Qt开发专栏各种问题解决(点击传送门 问题 兼容Qt4、Qt5的项目移植到Qt6出现找不到“QDesktopWidget和”QApplication-desktop()的问题本篇是兼容Qt6的解决方法。 原因 因为Qt6已经删除了QDesktopWidget和QApplication-desktop()。 解决方法
修改1头文件 修改前
#include QDesktopWidget修改后
#if QT_VERSION QT_VERSION_CHECK(6, 0, 0)
#include QScreen
#else
#include QDesktopWidget
#endif修改2使用到desktop的地方都要修改 修改前 _pKeyboardWidget-move(0, qApp-desktop()-height() - _pKeyboardWidget-height());修改后
#if QT_VERSION QT_VERSION_CHECK(6, 0, 0)QScreen *pScreen QApplication::primaryScreen();_pKeyboardWidget-move(0, pScreen-geometry().height() - _pKeyboardWidget-height());
#else_pKeyboardWidget-move(0, qApp-desktop()-height() - _pKeyboardWidget-height());
#endif修改前 setFixedSize(qApp-desktop()-width(), 380);修改后
#if QT_VERSION QT_VERSION_CHECK(6, 0, 0)QScreen *pScreen QApplication::primaryScreen();setFixedSize(pScreen-geometry().width(), 380);
#elsesetFixedSize(qApp-desktop()-width(), 380);
#endif本文章博客地址https://hpzwl.blog.csdn.net/article/details/140036861