From 1efeb1cb61947e69b8c99ddbfc5b75cd27013a87 Mon Sep 17 00:00:00 2001 From: Yurii Kolesnykov Date: Wed, 14 Dec 2022 19:52:13 +0200 Subject: [PATCH] fixes for building examples with Qt6 Signed-off-by: Yurii Kolesnykov --- examples/books/CMakeLists.txt | 10 ++++++++-- examples/codegen/CMakeLists.txt | 9 +++++++-- examples/codegen/designwidget.h | 2 +- examples/codegen/mainwindow.h | 2 +- examples/contacts/mainwindow.h | 4 ++-- examples/textedit/CMakeLists.txt | 23 ++++++++++++++--------- 6 files changed, 33 insertions(+), 17 deletions(-) diff --git a/examples/books/CMakeLists.txt b/examples/books/CMakeLists.txt index d75f5b09..1e617b44 100644 --- a/examples/books/CMakeLists.txt +++ b/examples/books/CMakeLists.txt @@ -16,8 +16,13 @@ get_filename_component(Grantlee_PLUGIN_DIR ${Grantlee_PLUGIN_DIR} PATH) configure_file(grantlee_paths.h.cmake ${PROJECT_BINARY_DIR}/grantlee_paths.h) -find_package(Qt5Widgets REQUIRED) -find_package(Qt5Sql REQUIRED) +if (GRANTLEE_BUILD_WITH_QT6) + find_package(Qt6Widgets REQUIRED) + find_package(Qt6Sql REQUIRED) +else() + find_package(Qt5Widgets REQUIRED) + find_package(Qt5Sql REQUIRED) +endif() add_executable(books main.cpp @@ -31,6 +36,7 @@ target_link_libraries( books Grantlee5::Templates ) + if (GRANTLEE_BUILD_WITH_QT6) target_link_libraries(books Qt6::Widgets diff --git a/examples/codegen/CMakeLists.txt b/examples/codegen/CMakeLists.txt index c72b25fc..90823b2a 100644 --- a/examples/codegen/CMakeLists.txt +++ b/examples/codegen/CMakeLists.txt @@ -16,7 +16,7 @@ get_filename_component(Grantlee_PLUGIN_DIR ${Grantlee_PLUGIN_DIR} PATH) configure_file(grantlee_paths.h.cmake ${PROJECT_BINARY_DIR}/grantlee_paths.h) -qt5_add_resources( +qt_add_resources( codegen_example_RCS_SRCS custom_tags.qrc OPTIONS -root "/plugins/grantlee/${Grantlee5_VERSION_MAJOR}.${Grantlee5_VERSION_MINOR}/" @@ -35,12 +35,17 @@ add_executable(codegen ) target_compile_definitions(codegen PRIVATE QT_DISABLE_DEPRECATED_BEFORE=0) -find_package(Qt5Widgets REQUIRED) +if (GRANTLEE_BUILD_WITH_QT6) + find_package(Qt6Widgets REQUIRED) +else() + find_package(Qt5Widgets REQUIRED) +endif() target_link_libraries( codegen Grantlee5::Templates ) + if (GRANTLEE_BUILD_WITH_QT6) target_link_libraries(codegen Qt6::Widgets diff --git a/examples/codegen/designwidget.h b/examples/codegen/designwidget.h index b93357ad..64723913 100644 --- a/examples/codegen/designwidget.h +++ b/examples/codegen/designwidget.h @@ -34,7 +34,7 @@ class DesignWidget : public QWidget { Q_OBJECT public: - DesignWidget(QWidget *parent = 0, Qt::WindowFlags f = 0); + DesignWidget(QWidget *parent = 0, Qt::WindowFlags f = Qt::Widget); Grantlee::Context getContext(); diff --git a/examples/codegen/mainwindow.h b/examples/codegen/mainwindow.h index 0511225c..dfffbd7c 100644 --- a/examples/codegen/mainwindow.h +++ b/examples/codegen/mainwindow.h @@ -36,7 +36,7 @@ class MainWindow : public QMainWindow { Q_OBJECT public: - MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); + MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = Qt::Widget); virtual ~MainWindow(); private Q_SLOTS: diff --git a/examples/contacts/mainwindow.h b/examples/contacts/mainwindow.h index dd6c459f..55b9c777 100644 --- a/examples/contacts/mainwindow.h +++ b/examples/contacts/mainwindow.h @@ -39,7 +39,7 @@ class MainWindow : public QWidget Q_OBJECT public: MainWindow(const QString &templateDir, QWidget *parent = 0, - Qt::WindowFlags f = 0); + Qt::WindowFlags f = Qt::Widget); protected: virtual void initLocalizer(); @@ -65,7 +65,7 @@ template class AppMainWindow : public MainWindow { public: AppMainWindow(const QString &templateDir, QWidget *parent = 0, - Qt::WindowFlags f = 0) + Qt::WindowFlags f = Qt::Widget) : MainWindow(templateDir, parent, f) { } diff --git a/examples/textedit/CMakeLists.txt b/examples/textedit/CMakeLists.txt index 2eab773b..35463837 100644 --- a/examples/textedit/CMakeLists.txt +++ b/examples/textedit/CMakeLists.txt @@ -3,7 +3,12 @@ cmake_minimum_required(VERSION 3.5) project(textedit_grantlee) find_package(Grantlee5 REQUIRED) -find_package(Qt5Widgets REQUIRED) + +if (GRANTLEE_BUILD_WITH_QT6) + find_package(Qt6Widgets REQUIRED) +else() + find_package(Qt5Widgets REQUIRED) +endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) @@ -47,13 +52,13 @@ target_link_libraries( ) if (GRANTLEE_BUILD_WITH_QT6) - target_link_libraries( - textedit - Qt6::Widgets - ) + target_link_libraries( + textedit + Qt6::Widgets + ) else() - target_link_libraries( - textedit - Qt5::Widgets - ) + target_link_libraries( + textedit + Qt5::Widgets + ) endif()