Skip to content

Commit 3e831d9

Browse files
committed
Qt 6
Updated and fixed the Qt demo to use Qt6 now it is released.
1 parent 646b5ed commit 3e831d9

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

config_qt_imgui.bat

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set CURRENT_DIR=%CD%
2+
mkdir build > nul
3+
cd build
4+
5+
cmake -G "Visual Studio 17 2022" -DBUILD_QT=YES -DBUILD_IMGUI=YES ..\
6+
cd "%CURRENT_DIR%"
7+

demos/demo_qt/CMakeLists.txt

+13-13
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ find_package(SDL2 REQUIRED)
1414
include(CMakePackageConfigHelpers)
1515

1616
find_package(MUtils REQUIRED)
17-
find_package(Qt5 COMPONENTS Core Widgets Gui REQUIRED)
17+
find_package(Qt6 COMPONENTS Core Widgets Gui REQUIRED)
1818

1919
set_property(GLOBAL PROPERTY AUTOMOC_FOLDER Automoc)
2020
set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER Automoc)
@@ -57,18 +57,18 @@ target_include_directories(${DEMO_NAME}
5757
${DEMO_ROOT}/demo_qt
5858
${ZEP_ROOT}/src/qt
5959
${ZEP_ROOT}/demos
60-
${Qt5Widgets_INCLUDE_DIRS}
61-
${Qt5Gui_INCLUDE_DIRS}
62-
${Qt5Core_INCLUDE_DIRS}
60+
${Qt6Widgets_INCLUDE_DIRS}
61+
${Qt6Gui_INCLUDE_DIRS}
62+
${Qt6Core_INCLUDE_DIRS}
6363
${CMAKE_BINARY_DIR}
6464
${M3RDPARTY_DIR}
6565
${ZEP_ROOT}/include)
6666

6767
target_link_libraries(${DEMO_NAME} PRIVATE
6868
MUtils::MUtils
69-
Qt5::Core
70-
Qt5::Gui
71-
Qt5::Widgets
69+
Qt6::Core
70+
Qt6::Gui
71+
Qt6::Widgets
7272
Zep
7373
ZepExtensions
7474
#efsw::efsw
@@ -122,9 +122,9 @@ install(DIRECTORY ${ZEP_ROOT}/include/zep
122122
# NOTE:
123123
# This unfortunate mess is handling the problem of deploying Qt into the install folder.
124124
# It takes the Qt deploy application output into a folder and copies it to the install location
125-
if(Qt5_FOUND AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt)
125+
if(Qt6_FOUND AND WIN32 AND TARGET Qt6::qmake AND NOT TARGET Qt6::windeployqt)
126126
MESSAGE(STATUS "Found Qt for deploy")
127-
get_target_property(_qt5_qmake_location Qt5::qmake IMPORTED_LOCATION)
127+
get_target_property(_qt6_qmake_location Qt6::qmake IMPORTED_LOCATION)
128128

129129
execute_process(
130130
COMMAND "${_qt5_qmake_location}" -query QT_INSTALL_PREFIX
@@ -136,21 +136,21 @@ if(Qt5_FOUND AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt)
136136
set(imported_location "${qt5_install_prefix}/bin/windeployqt.exe")
137137

138138
if(EXISTS ${imported_location})
139-
add_executable(Qt5::windeployqt IMPORTED)
139+
add_executable(Qt6::windeployqt IMPORTED)
140140

141-
set_target_properties(Qt5::windeployqt PROPERTIES
141+
set_target_properties(Qt6::windeployqt PROPERTIES
142142
IMPORTED_LOCATION ${imported_location}
143143
)
144144
endif()
145145
endif()
146146

147-
if(TARGET Qt5::windeployqt)
147+
if(TARGET Qt6::windeployqt)
148148
# execute windeployqt in a tmp directory after build
149149
add_custom_command(TARGET ${DEMO_NAME}
150150
POST_BUILD
151151
COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/windeployqt"
152152
COMMAND set PATH=%PATH%$<SEMICOLON>${qt5_install_prefix}/bin
153-
COMMAND Qt5::windeployqt --dir "${CMAKE_CURRENT_BINARY_DIR}/windeployqt" "$<TARGET_FILE_DIR:${DEMO_NAME}>/$<TARGET_FILE_NAME:${DEMO_NAME}>"
153+
COMMAND Qt6::windeployqt --dir "${CMAKE_CURRENT_BINARY_DIR}/windeployqt" "$<TARGET_FILE_DIR:${DEMO_NAME}>/$<TARGET_FILE_NAME:${DEMO_NAME}>"
154154
)
155155

156156
# copy deployment directory during installation

include/zep/qt/common_qt.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include <QApplication>
4-
#include <QDesktopWidget>
54
#include <QFont>
65
#include <QIcon>
76
#include <QPainter>

include/zep/qt/zepdisplay_qt.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class ZepDisplay_Qt : public ZepDisplay
100100
public:
101101
using TParent = ZepDisplay;
102102

103-
ZepDisplay_Qt(const NVec2f& pixelScale)
104-
: ZepDisplay(pixelScale)
103+
ZepDisplay_Qt()
104+
: ZepDisplay()
105105
{
106106
}
107107

include/zep/qt/zepwidget_qt.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include <QClipboard>
88
#include <QDebug>
9-
#include <QDesktopWidget>
109
#include <QKeyEvent>
1110

1211
#include "zep/editor.h"
@@ -36,7 +35,7 @@ class ZepWidget_Qt : public QWidget, public IZepComponent
3635
NVec2f pixelScale(NVec2f(qRound(qApp->primaryScreen()->logicalDotsPerInchX() / 96.0f), qRound(qApp->primaryScreen()->logicalDotsPerInchY() / 96.0f)));
3736
#endif
3837

39-
m_spEditor = std::make_unique<ZepEditor>(new ZepDisplay_Qt(pixelScale), root);
38+
m_spEditor = std::make_unique<ZepEditor>(new ZepDisplay_Qt(), root);
4039
m_spEditor->RegisterCallback(this);
4140

4241
auto ptToPx = [](float pt, float dpi) {

0 commit comments

Comments
 (0)