Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt6 migrations that are compatible with Qt5 #598

Merged
merged 26 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4f98aa3
Change main gui classes to implptr
mjcarroll Oct 5, 2023
ed63b7b
Switch gz-gui plugins to use implptr
mjcarroll Oct 5, 2023
2052269
First pass at level1 clazy checks for qt
mjcarroll Nov 7, 2023
5e9bc27
Merge branch 'main' into mjcarroll/clazy
mjcarroll Nov 10, 2023
364fbca
Lint
mjcarroll Nov 10, 2023
273fac0
Make use of auto* more consistent
mjcarroll Nov 13, 2023
44bd786
Make cmake qt-version agnostic
mjcarroll Nov 13, 2023
bc58d59
lambda capture
mjcarroll Nov 13, 2023
451450a
Merge branch 'mjcarroll/clazy' into mjcarroll/qt5qt6
mjcarroll Nov 13, 2023
6c35be0
Remove qt5 from examples
mjcarroll Nov 13, 2023
126b690
Remove Qt < 5.15 logic
mjcarroll Nov 13, 2023
ffa6430
Additional qt5 cmake functions
mjcarroll Nov 13, 2023
6ebe89c
Fix conversions test
mjcarroll Nov 13, 2023
fa6e270
Make using deprecated APIs an error
mjcarroll Nov 13, 2023
9f6c81c
Fix vulkan call and qregexp
mjcarroll Nov 13, 2023
8eba03e
Fix test logic
mjcarroll Nov 13, 2023
22cb41a
Qt5.15 compatible graphics updates
mjcarroll Nov 13, 2023
4c7d46d
Fix extra header
mjcarroll Nov 13, 2023
7584829
Lint
mjcarroll Nov 13, 2023
06c80fd
Merge branch 'main' into mjcarroll/qt5qt6
mjcarroll Nov 20, 2023
5ee29c6
Fix preprocessor
mjcarroll Nov 27, 2023
b255e56
Fix indent
mjcarroll Nov 27, 2023
dffd3a0
Fix regex use
mjcarroll Nov 27, 2023
2d3fd2a
Fix indentation
mjcarroll Dec 7, 2023
b4b1149
Merge branch 'main' into mjcarroll/qt5qt6
mjcarroll Dec 7, 2023
acb224b
Merge remote-tracking branch 'origin/mjcarroll/qt5qt6' into mjcarroll…
mjcarroll Dec 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,19 @@ set(GZ_TOOLS_VER 2)

#--------------------------------------
# Find QT
gz_find_package (Qt5
set(QT_MAJOR_VERSION 5)
set(QT_MINOR_VERSION 15)
gz_find_package (Qt${QT_MAJOR_VERSION}
VERSION ${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}
COMPONENTS
Core
Quick
QuickControls2
Widgets
Test
REQUIRED
PKGCONFIG "Qt5Core Qt5Quick Qt5QuickControls2 Qt5Widgets"
)
PKGCONFIG "Qt${QT_MAJOR_VERSION}Core Qt${QT_MAJOR_VERSION}Quick Qt${QT_MAJOR_VERSION}QuickControls2 Qt${QT_MAJOR_VERSION}Widgets")
add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00)

set(GZ_GUI_PLUGIN_RELATIVE_INSTALL_DIR
${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins
Expand Down
10 changes: 2 additions & 8 deletions examples/plugin/custom_context_menu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ endif()
set (CMAKE_AUTOMOC ON)

# Find Qt5
find_package (Qt5
find_package (Qt5 5.15
COMPONENTS
Core
Quick
Expand All @@ -21,9 +21,7 @@ find_package (Qt5
find_package(gz-gui9 REQUIRED)
set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR})

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}")

QT5_ADD_RESOURCES(resources_RCC CustomContext.qrc)
qt_add_resources(resources_RCC CustomContext.qrc)

# Generate examples
add_library(CustomContext SHARED ${headers_MOC}
Expand All @@ -32,8 +30,4 @@ add_library(CustomContext SHARED ${headers_MOC}
)
target_link_libraries(CustomContext
gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER}
${Qt5Core_LIBRARIES}
${Qt5Qml_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5QuickControls2_LIBRARIES}
)
9 changes: 1 addition & 8 deletions examples/plugin/dialog_from_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ endif()

set (CMAKE_AUTOMOC ON)

# Find Qt5
find_package (Qt5
COMPONENTS
Core
Expand All @@ -21,9 +20,7 @@ find_package (Qt5
find_package(gz-gui9 REQUIRED)
set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR})

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}")

QT5_ADD_RESOURCES(resources_RCC DialogFromPlugin.qrc)
qt_add_resources(resources_RCC DialogFromPlugin.qrc)

# Generate examples
add_library(DialogFromPlugin SHARED ${headers_MOC}
Expand All @@ -32,8 +29,4 @@ add_library(DialogFromPlugin SHARED ${headers_MOC}
)
target_link_libraries(DialogFromPlugin
gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER}
${Qt5Core_LIBRARIES}
${Qt5Qml_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5QuickControls2_LIBRARIES}
)
8 changes: 2 additions & 6 deletions examples/plugin/gz_components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif()

set (CMAKE_AUTOMOC ON)

find_package (Qt5
find_package (Qt5 5.15
COMPONENTS
Core
Quick
Expand All @@ -21,7 +21,7 @@ set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR})

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}")

QT5_ADD_RESOURCES(resources_RCC GzComponents.qrc)
qt_add_resources(resources_RCC GzComponents.qrc)

# Generate examples
add_library(GzComponents SHARED ${headers_MOC}
Expand All @@ -30,8 +30,4 @@ add_library(GzComponents SHARED ${headers_MOC}
)
target_link_libraries(GzComponents
gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER}
${Qt5Core_LIBRARIES}
${Qt5Qml_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5QuickControls2_LIBRARIES}
)
11 changes: 2 additions & 9 deletions examples/plugin/hello_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ endif()

set (CMAKE_AUTOMOC ON)

# Find Qt5
find_package (Qt5
find_package (Qt5 5.15
COMPONENTS
Core
Quick
Expand All @@ -21,9 +20,7 @@ find_package (Qt5
find_package(gz-gui9 REQUIRED)
set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR})

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}")

QT5_ADD_RESOURCES(resources_RCC hello.qrc)
qt_add_resources(resources_RCC hello.qrc)

# Generate examples
add_library(HelloPlugin SHARED ${headers_MOC}
Expand All @@ -32,8 +29,4 @@ add_library(HelloPlugin SHARED ${headers_MOC}
)
target_link_libraries(HelloPlugin
gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER}
${Qt5Core_LIBRARIES}
${Qt5Qml_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5QuickControls2_LIBRARIES}
)
7 changes: 1 addition & 6 deletions examples/plugin/multiple_qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ endif()

set (CMAKE_AUTOMOC ON)

# Find Qt5
find_package (Qt5
COMPONENTS
Core
Expand All @@ -23,7 +22,7 @@ set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR})

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}")

QT5_ADD_RESOURCES(resources_RCC MultipleQml.qrc)
qt_add_resources(resources_RCC MultipleQml.qrc)

# Generate examples
add_library(MultipleQml SHARED ${headers_MOC}
Expand All @@ -32,8 +31,4 @@ add_library(MultipleQml SHARED ${headers_MOC}
)
target_link_libraries(MultipleQml
gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER}
${Qt5Core_LIBRARIES}
${Qt5Qml_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5QuickControls2_LIBRARIES}
)
8 changes: 1 addition & 7 deletions examples/standalone/custom_drawer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ find_package (Qt5
find_package(gz-gui9 REQUIRED)
set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR})

QT5_ADD_RESOURCES(resources_RCC custom_drawer.qrc)

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}")
qt_add_resources(resources_RCC custom_drawer.qrc)

# Generate example
add_executable(custom_drawer
Expand All @@ -32,8 +30,4 @@ add_executable(custom_drawer
)
target_link_libraries(custom_drawer
gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER}
${Qt5Core_LIBRARIES}
${Qt5Qml_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5QuickControls2_LIBRARIES}
)
10 changes: 1 addition & 9 deletions examples/standalone/dialogs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ endif()

set (CMAKE_AUTOMOC ON)

# Find Qt5
find_package (Qt5
find_package (Qt5 5.15
COMPONENTS
Core
Quick
Expand All @@ -21,17 +20,10 @@ find_package (Qt5
find_package(gz-gui9 REQUIRED)
set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR})

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}")

# Generate example
add_executable(dialogs
dialogs.cc
)
target_link_libraries(dialogs
gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER}
${Qt5Core_LIBRARIES}
${Qt5Qml_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5QuickControls2_LIBRARIES}
)

7 changes: 1 addition & 6 deletions examples/standalone/window/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ endif()
set (CMAKE_AUTOMOC ON)

# Find Qt5
find_package (Qt5
find_package (Qt5 5.15
COMPONENTS
Core
Quick
Expand All @@ -29,9 +29,4 @@ add_executable(window
)
target_link_libraries(window
gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER}
${Qt5Core_LIBRARIES}
${Qt5Qml_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5QuickControls2_LIBRARIES}
)

32 changes: 7 additions & 25 deletions include/gz/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
include_directories(
${Qt5Core_INCLUDE_DIRS}
${tinyxml_INCLUDE_DIRS}
${Qt5Qml_INCLUDE_DIRS}
${Qt5Quick_INCLUDE_DIRS}
${Qt5QuickControls2_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)

if(POLICY CMP0100)
cmake_policy(SET CMP0100 NEW)
endif()

set (CMAKE_AUTOMOC ON)

add_definitions(
${Qt5Core_DEFINITIONS}
${Qt5Qml_DEFINITIONS}
${Qt5Quick_DEFINITIONS}
${Qt5QuickControls2_DEFINITIONS}
${Qt5Widgets_DEFINITIONS}
)

set (qt_headers
Application.hh
Dialog.hh
Expand All @@ -42,8 +25,8 @@ set (headers

set (resources resources.qrc)

QT5_WRAP_CPP(headers_MOC ${qt_headers})
QT5_ADD_RESOURCES(resources_RCC ${resources})
qt_wrap_cpp(headers_MOC ${qt_headers})
qt_add_resources(resources_RCC ${resources})

gz_create_core_library(SOURCES
${sources}
Expand All @@ -67,13 +50,12 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
gz-msgs${GZ_MSGS_VER}::gz-msgs${GZ_MSGS_VER}
gz-plugin${GZ_PLUGIN_VER}::loader
gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER}
${Qt5Core_LIBRARIES}
${Qt5Qml_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5QuickControls2_LIBRARIES}
${Qt5Widgets_LIBRARIES}
Qt::Core
Qt::Qml
Qt::Quick
Qt::QuickControls2
Qt::Widgets
TINYXML2::TINYXML2
)

gz_install_all_headers()

12 changes: 10 additions & 2 deletions src/Application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
*/

#include <qsgrendererinterface.h>
#include <tinyxml2.h>
#include <queue>

Expand Down Expand Up @@ -126,7 +127,12 @@ Application::Application(int &_argc, char **_argv, const WindowType _type,
{
// Use the Metal graphics API on macOS.
gzdbg << "Qt using Metal graphics interface" << std::endl;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QQuickWindow::setGraphicsApi(QSGRendererInterface::MetalRhi);
#else
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::MetalRhi);
#endif

}

// TODO(srmainwaring): implement facility for overriding the default
Expand Down Expand Up @@ -161,9 +167,11 @@ Application::Application(int &_argc, char **_argv, const WindowType _type,
# endif
);

# if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan)
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QQuickWindow::setGraphicsApi(QSGRendererInterface::VulkanRhi);
#else
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::VulkanRhi);
# endif
#endif
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ gz_build_tests(TYPE UNIT
TINYXML2::TINYXML2
TEST_LIST
gtest_targets
ENVIRONMENT
ENVIRONMENT
GZ_GUI_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)

Expand Down
4 changes: 0 additions & 4 deletions src/Conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ gz::common::MouseEvent convert(const QWheelEvent &_e)
common::MouseEvent event;

event.SetType(common::MouseEvent::SCROLL);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
event.SetPos(_e.x(), _e.y());
#else
event.SetPos(_e.position().x(), _e.position().y());
#endif
double scroll = (_e.angleDelta().y() > 0) ? -1.0 : 1.0;
event.SetScroll(scroll, scroll);

Expand Down
Loading