From e8b68cf0c4fcce2121bb74213995829bc828d182 Mon Sep 17 00:00:00 2001 From: shouchih_chen Date: Fri, 20 Sep 2024 13:25:29 +0800 Subject: [PATCH] Improve compatibility between Qt5 and Qt6 --- NameCreater/NameCreater.pro.user | 34 ++++++++++++++++++-------------- NameCreater/NameCreater.vcxproj | 4 ++-- NameCreater/customlogo.cpp | 10 ++++++++-- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/NameCreater/NameCreater.pro.user b/NameCreater/NameCreater.pro.user index 2a02054..3192816 100644 --- a/NameCreater/NameCreater.pro.user +++ b/NameCreater/NameCreater.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -8,7 +8,7 @@ ProjectExplorer.Project.ActiveTarget - 2 + 1 ProjectExplorer.Project.EditorSettings @@ -403,11 +403,13 @@ false -e cpu-cycles --call-graph "dwarf,4096" -F 250 - ProjectExplorer.CustomExecutableRunConfiguration - + Qt4ProjectManager.Qt4RunConfiguration:C:/dev/namecreater/NameCreater/NameCreater.pro + C:/dev/namecreater/NameCreater/NameCreater.pro false true + true true + C:/dev/namecreater/NameCreater/build/Desktop_Qt_5_15_2_MSVC2019_64bit-Debug 1 @@ -416,16 +418,16 @@ ProjectExplorer.Project.Target.2 Desktop - Desktop Qt 6.7.2 MinGW 64-bit - Desktop Qt 6.7.2 MinGW 64-bit - qt.qt6.672.win64_mingw_kit + Desktop Qt 6.7.2 MSVC2019 64bit + Desktop Qt 6.7.2 MSVC2019 64bit + qt.qt6.672.win64_msvc2019_64_kit 0 0 0 0 - C:\dev\namecreater\NameCreater\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug - C:/dev/namecreater/NameCreater/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug + C:\dev\namecreater\NameCreater\build\Desktop_Qt_6_7_2_MSVC2019_64bit-Debug + C:/dev/namecreater/NameCreater/build/Desktop_Qt_6_7_2_MSVC2019_64bit-Debug true @@ -463,8 +465,8 @@ 2 - C:\dev\namecreater\NameCreater\build\Desktop_Qt_6_7_2_MinGW_64_bit-Release - C:/dev/namecreater/NameCreater/build/Desktop_Qt_6_7_2_MinGW_64_bit-Release + C:\dev\namecreater\NameCreater\build\Desktop_Qt_6_7_2_MSVC2019_64bit-Release + C:/dev/namecreater/NameCreater/build/Desktop_Qt_6_7_2_MSVC2019_64bit-Release true @@ -504,8 +506,8 @@ 0 - C:\dev\namecreater\NameCreater\build\Desktop_Qt_6_7_2_MinGW_64_bit-Profile - C:/dev/namecreater/NameCreater/build/Desktop_Qt_6_7_2_MinGW_64_bit-Profile + C:\dev\namecreater\NameCreater\build\Desktop_Qt_6_7_2_MSVC2019_64bit-Profile + C:/dev/namecreater/NameCreater/build/Desktop_Qt_6_7_2_MSVC2019_64bit-Profile true @@ -570,11 +572,13 @@ false -e cpu-cycles --call-graph "dwarf,4096" -F 250 - ProjectExplorer.CustomExecutableRunConfiguration - + Qt4ProjectManager.Qt4RunConfiguration:C:/dev/namecreater/NameCreater/NameCreater.pro + C:/dev/namecreater/NameCreater/NameCreater.pro false true + true true + C:/dev/namecreater/NameCreater/build/Desktop_Qt_6_7_2_MSVC2019_64bit-Debug 1 diff --git a/NameCreater/NameCreater.vcxproj b/NameCreater/NameCreater.vcxproj index 49de0e4..acd4265 100644 --- a/NameCreater/NameCreater.vcxproj +++ b/NameCreater/NameCreater.vcxproj @@ -55,7 +55,7 @@ $(DefaultQtVersion) - core;gui;widgets;network;core5compat + core;gui;widgets;network;core5compat debug @@ -65,7 +65,7 @@ $(DefaultQtVersion) - core;gui;widgets;network; + core;gui;widgets;network;core5compat release diff --git a/NameCreater/customlogo.cpp b/NameCreater/customlogo.cpp index c68d35b..9a3e825 100644 --- a/NameCreater/customlogo.cpp +++ b/NameCreater/customlogo.cpp @@ -106,9 +106,15 @@ void CustomLogo::gerneraImageFromList(const QList& nameList, Name_Ty scene.addItem(bg_item); } - QPixmap* _bg = new QPixmap(ui->display_label->pixmap().copy()); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QPixmap _bg = ui->display_label->pixmap()->copy(); +#else + QPixmap _bg = ui->display_label->pixmap().copy(); +#endif // - QGraphicsPixmapItem* name_bgItem = new QGraphicsPixmapItem(*_bg); + + + QGraphicsPixmapItem* name_bgItem = new QGraphicsPixmapItem(_bg); bool rot = (idx == 10 || idx == 11); name_bgItem->setRotation(rot ? -90 : 0); name_bgItem->setPos(BG_POS[idx]);