diff --git a/Applications/Testing/Cpp/CMakeLists.txt b/Applications/Testing/Cpp/CMakeLists.txt index 3a9ba51dab..b10938332d 100644 --- a/Applications/Testing/Cpp/CMakeLists.txt +++ b/Applications/Testing/Cpp/CMakeLists.txt @@ -33,7 +33,7 @@ if(CTK_APP_ctkDICOMQuery AND CTK_APP_ctkDICOMRetrieve) if(CTK_QT_VERSION VERSION_LESS "5") target_link_libraries(ctkDICOMApplicationTest1 ${QT_LIBRARIES}) else() - target_link_libraries(ctkDICOMApplicationTest1 Qt5::Core) + target_link_libraries(ctkDICOMApplicationTest1 Qt${CTK_QT_VERSION}::Core) endif() ADD_TEST( NAME ctkDICOMApplicationTest1 diff --git a/Applications/ctkExampleHost/CMakeLists.txt b/Applications/ctkExampleHost/CMakeLists.txt index 335ae2bb90..181ff06a3d 100644 --- a/Applications/ctkExampleHost/CMakeLists.txt +++ b/Applications/ctkExampleHost/CMakeLists.txt @@ -30,7 +30,7 @@ set(KIT_resources ctkFunctionGetTargetLibraries(KIT_target_libraries) if(CTK_QT_VERSION VERSION_GREATER "4") - list(APPEND KIT_target_libraries Qt5::Widgets) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::Widgets) endif() ctkMacroBuildApp( diff --git a/Applications/ctkPluginBrowser/CMakeLists.txt b/Applications/ctkPluginBrowser/CMakeLists.txt index ecbc67d2d4..3ae5b4ef65 100644 --- a/Applications/ctkPluginBrowser/CMakeLists.txt +++ b/Applications/ctkPluginBrowser/CMakeLists.txt @@ -35,7 +35,7 @@ set(KIT_resources ctkFunctionGetTargetLibraries(KIT_target_libraries) if(CTK_QT_VERSION VERSION_GREATER "4") - list(APPEND KIT_target_libraries Qt5::Widgets) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::Widgets) endif() ctkMacroBuildApp( diff --git a/CMake/CMakeFindDependencyMacro.cmake b/CMake/CMakeFindDependencyMacro.cmake index 2da2cf0231..225a3202f7 100644 --- a/CMake/CMakeFindDependencyMacro.cmake +++ b/CMake/CMakeFindDependencyMacro.cmake @@ -65,14 +65,16 @@ macro(find_dependency dep) set(cmake_fd_version ${ARGV1}) endif() set(cmake_fd_exact_arg) - if(${ARGC} GREATER 2) - if (NOT "${ARGV2}" STREQUAL EXACT) + if(CTK_QT_VERSION VERSION_LESS "6") + if(${ARGC} GREATER 2) + if (NOT "${ARGV2}" STREQUAL EXACT) + message(FATAL_ERROR "Invalid arguments to find_dependency") + endif() + set(cmake_fd_exact_arg EXACT) + endif() + if(${ARGC} GREATER 3) message(FATAL_ERROR "Invalid arguments to find_dependency") endif() - set(cmake_fd_exact_arg EXACT) - endif() - if(${ARGC} GREATER 3) - message(FATAL_ERROR "Invalid arguments to find_dependency") endif() set(cmake_fd_quiet_arg) if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) diff --git a/CMake/ctkMacroBuildLib.cmake b/CMake/ctkMacroBuildLib.cmake index 89f10e11b6..c2f0f58691 100644 --- a/CMake/ctkMacroBuildLib.cmake +++ b/CMake/ctkMacroBuildLib.cmake @@ -119,7 +119,7 @@ ${${MY_EXPORT_CUSTOM_CONTENT_FROM_VARIABLE}} # moc files can get very long and can't be resolved by the MSVC compiler. if(CTK_QT_VERSION VERSION_GREATER "4") foreach(moc_src ${MY_MOC_SRCS}) - qt5_wrap_cpp(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src} OPTIONS -DHAVE_QT5) + qt_wrap_cpp(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src} OPTIONS "-DHAVE_QT${CTK_QT_VERSION}") endforeach() else() foreach(moc_src ${MY_MOC_SRCS}) @@ -130,8 +130,15 @@ ${${MY_EXPORT_CUSTOM_CONTENT_FROM_VARIABLE}} if(MY_GENERATE_MOC_SRCS) QT4_GENERATE_MOCS(${MY_GENERATE_MOC_SRCS}) endif() - if(CTK_QT_VERSION VERSION_GREATER "4") - if(Qt5Widgets_FOUND) + if(CTK_QT_VERSION VERSION_GREATER "5") + if(Qt6Widgets_FOUND OR Qt6_FOUND) + qt_wrap_ui(MY_UI_CPP ${MY_UI_FORMS}) + elseif(MY_UI_FORMS) + message(FATAL_ERROR "Argument UI_FORMS ignored because Qt6Widgets module was not specified") + endif() + elseif(CTK_QT_VERSION VERSION_GREATER "4") + MESSAGE(STATUS "CALLING QT WRAPUI 5") + if(Qt5Widgets_FOUND) qt5_wrap_ui(MY_UI_CPP ${MY_UI_FORMS}) elseif(MY_UI_FORMS) message(WARNING "Argument UI_FORMS ignored because Qt5Widgets module was not specified") @@ -140,7 +147,9 @@ ${${MY_EXPORT_CUSTOM_CONTENT_FROM_VARIABLE}} QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS}) endif() if(DEFINED MY_RESOURCES AND NOT MY_RESOURCES STREQUAL "") - if(CTK_QT_VERSION VERSION_GREATER "4") + if(CTK_QT_VERSION VERSION_GREATER "5") + qt_add_resources(MY_QRC_SRCS ${MY_RESOURCES}) + elseif(CTK_QT_VERSION VERSION_GREATER "4") qt5_add_resources(MY_QRC_SRCS ${MY_RESOURCES}) else() QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES}) diff --git a/CMake/ctkMacroBuildPlugin.cmake b/CMake/ctkMacroBuildPlugin.cmake index e41ad9b599..c83f0959de 100644 --- a/CMake/ctkMacroBuildPlugin.cmake +++ b/CMake/ctkMacroBuildPlugin.cmake @@ -150,7 +150,7 @@ macro(ctkMacroBuildPlugin) # Add Qt include dirs and defines include(${QT_USE_FILE}) else() - find_package(Qt5 COMPONENTS LinguistTools REQUIRED) + find_package(Qt${CTK_QT_VERSION} COMPONENTS LinguistTools REQUIRED) endif() # Add the library directories from the external project @@ -316,16 +316,16 @@ macro(ctkMacroBuildPlugin) endforeach() endif() else() - find_package(Qt5LinguistTools REQUIRED) + find_package(Qt${CTK_QT_VERSION}LinguistTools REQUIRED) endif() if(MY_TEST_PLUGIN AND CTK_QT_VERSION VERSION_GREATER "4") - find_package(Qt5Test REQUIRED) - if(CMAKE_VERSION VERSION_LESS 2.8.12) - target_link_libraries(${lib_name} Qt5::Test) - else() - target_link_libraries(${lib_name} PRIVATE Qt5::Test) - endif() + find_package(Qt${CTK_QT_VERSION} Test REQUIRED) + if(CMAKE_VERSION VERSION_LESS 2.8.12) + target_link_libraries(${lib_name} Qt${CTK_QT_VERSION}::Test) + else() + target_link_libraries(${lib_name} PRIVATE Qt${CTK_QT_VERSION}::Test) + endif() endif() # Set the output directory for the plugin diff --git a/CMake/ctkMacroBuildQtPlugin.cmake b/CMake/ctkMacroBuildQtPlugin.cmake index 00af36bd80..b03e95da1f 100644 --- a/CMake/ctkMacroBuildQtPlugin.cmake +++ b/CMake/ctkMacroBuildQtPlugin.cmake @@ -89,13 +89,20 @@ macro(ctkMacroBuildQtPlugin) set(MY_QRC_SRCS "") if(CTK_QT_VERSION VERSION_GREATER "4") set(target) - if(Qt5Core_VERSION VERSION_GREATER "5.2.0") + if(Qt${CTK_QT_VERSION}Core_VERSION VERSION_GREATER "5.2.0") set(target TARGET ${MY_LIBNAME}) endif() - qt5_wrap_cpp(MY_MOC_CPP ${MY_MOC_SRCS} OPTIONS -DHAVE_QT5 ${target}) - + if(CTK_QT_VERSION VERSION_GREATER "5") + qt_wrap_cpp(MY_MOC_CPP ${MY_MOC_SRCS} OPTIONS -DHAVE_QT${CTK_QT_VERSION} ${target}) + else() + qt5_wrap_cpp(MY_MOC_CPP ${MY_MOC_SRCS} OPTIONS -DHAVE_QT${CTK_QT_VERSION} ${target}) + endif() if(DEFINED MY_RESOURCES) - qt5_add_resources(MY_QRC_SRCS ${MY_RESOURCES}) + if(CTK_QT_VERSION VERSION_GREATER "5") + qt_add_resources(MY_QRC_SRCS ${MY_RESOURCES}) + else() + qt5_add_resources(MY_QRC_SRCS ${MY_RESOURCES}) + endif() endif() else() QT4_WRAP_CPP(MY_MOC_CPP ${MY_MOC_SRCS}) @@ -191,9 +198,9 @@ endmacro() macro(ctkMacroBuildQtDesignerPlugin) if(CTK_QT_VERSION VERSION_GREATER "4") - find_package(Qt5 COMPONENTS Designer REQUIRED) - add_definitions(${Qt5Designer_DEFINITIONS}) - include_directories(${Qt5Designer_INCLUDE_DIRS}) + find_package(Qt${CTK_QT_VERSION} COMPONENTS Designer REQUIRED) + add_definitions(${Qt${CTK_QT_VERSION}Designer_DEFINITIONS}) + include_directories(${Qt${CTK_QT_VERSION}Designer_INCLUDE_DIRS}) endif() ctkMacroBuildQtPlugin( PLUGIN_DIR designer @@ -205,7 +212,7 @@ macro(ctkMacroBuildQtDesignerPlugin) "SRCS;MOC_SRCS;UI_FORMS;INCLUDE_DIRECTORIES;TARGET_LIBRARIES;RESOURCES" # multi value args ${ARGN} ) - target_link_libraries(${MY_NAME} Qt5::Designer) + target_link_libraries(${MY_NAME} Qt${CTK_QT_VERSION}::Designer) endif() endmacro() diff --git a/CMake/ctkMacroGenerateMocs.cmake b/CMake/ctkMacroGenerateMocs.cmake index 6306d995a4..a703a5a36a 100644 --- a/CMake/ctkMacroGenerateMocs.cmake +++ b/CMake/ctkMacroGenerateMocs.cmake @@ -5,7 +5,7 @@ include(MacroAddFileDependencies) function(_ctk_generate_mocs) if(CTK_QT_VERSION VERSION_GREATER "4") - if(Qt5_VERSION VERSION_LESS "5.15.0") + if(CTK_QT_VERSION VERSION_LESS "6") QT5_GET_MOC_FLAGS(_moc_flags) else() # _moc_flags is not needed because it is internally handled @@ -29,17 +29,19 @@ function(_ctk_generate_mocs) endif() set(moc_file ${CMAKE_CURRENT_BINARY_DIR}/moc_${source_name}${source_ext}) - - if(CTK_QT_VERSION VERSION_GREATER "4") + + if(CTK_QT_VERSION VERSION_GREATER "5") + qt_generate_moc(${abs_file} ${moc_file}) + elseif(CTK_QT_VERSION VERSION_GREATER "4") if(Qt5_VERSION VERSION_LESS "5.6") QT5_CREATE_MOC_COMMAND(${abs_file} ${moc_file} "${_moc_flags}" "" "") elseif(Qt5_VERSION VERSION_LESS "5.15.0") QT5_CREATE_MOC_COMMAND(${abs_file} ${moc_file} "${_moc_flags}" "" "" "") - else() + elseif(Qt5_VERSION VERSION_LESS "6") # qt5_generate_moc internally calls qt5_get_moc_flags and ensure # no warnings are reported. qt5_generate_moc(${abs_file} ${moc_file}) - endif() + endif() else() QT4_CREATE_MOC_COMMAND(${abs_file} ${moc_file} "${_moc_flags}" "" "") endif() @@ -56,3 +58,9 @@ endmacro() macro(QT5_GENERATE_MOCS) _ctk_generate_mocs(${ARGN}) endmacro() + + +# create a Qt5 alias +macro(QT6_GENERATE_MOCS) + _ctk_generate_mocs(${ARGN}) +endmacro() diff --git a/CMake/ctkMacroSetupPlugins.cmake b/CMake/ctkMacroSetupPlugins.cmake index 8f7428b73a..422ddeebb5 100644 --- a/CMake/ctkMacroSetupPlugins.cmake +++ b/CMake/ctkMacroSetupPlugins.cmake @@ -115,10 +115,10 @@ macro(ctkMacroSetupPlugins ) # Qt shared libraries if (CTK_QT_VERSION VERSION_GREATER "4") if(WIN32) - get_target_property(_qt5_moc_executable Qt5::moc LOCATION) + get_target_property(_qt5_moc_executable Qt${CTK_QT_VERSION}::moc LOCATION) get_filename_component(QT_INSTALLED_LIBRARY_DIR ${_qt5_moc_executable} PATH) else() - get_target_property(_qt5_core_lib Qt5::Core LOCATION) + get_target_property(_qt5_core_lib Qt${CTK_QT_VERSION}::Core LOCATION) get_filename_component(QT_INSTALLED_LIBRARY_DIR ${_qt5_core_lib} PATH) endif() else() diff --git a/CMake/ctkMacroSetupQt.cmake b/CMake/ctkMacroSetupQt.cmake index 617420d372..3b0fa29023 100644 --- a/CMake/ctkMacroSetupQt.cmake +++ b/CMake/ctkMacroSetupQt.cmake @@ -23,22 +23,48 @@ macro(ctkMacroSetupQt) set(CTK_QT_VERSION "4" CACHE STRING "Expected Qt version") mark_as_advanced(CTK_QT_VERSION) - set_property(CACHE CTK_QT_VERSION PROPERTY STRINGS 4 5) + set_property(CACHE CTK_QT_VERSION PROPERTY STRINGS 4 5 6) - if(NOT (CTK_QT_VERSION VERSION_EQUAL "4" OR CTK_QT_VERSION VERSION_EQUAL "5")) - message(FATAL_ERROR "Expected value for CTK_QT_VERSION is either '4' or '5'") + if(NOT (CTK_QT_VERSION VERSION_EQUAL "4" OR CTK_QT_VERSION VERSION_EQUAL "5" OR CTK_QT_VERSION VERSION_EQUAL "6")) + message(FATAL_ERROR "Expected value for CTK_QT_VERSION is either '4' or '5' or '6'") endif() + if(CTK_QT_VERSION VERSION_GREATER "5") + cmake_minimum_required(VERSION 2.8.12) + find_package(Qt6 COMPONENTS Core) + set(CTK_QT6_COMPONENTS Core Xml Concurrent Sql Test StateMachine Core5Compat) + # XmlPatterns + if(CTK_ENABLE_Widgets OR CTK_LIB_Widgets OR CTK_LIB_CommandLineModules/Frontend/QtGui OR CTK_BUILD_ALL OR CTK_BUILD_ALL_LIBRARIES) + list(APPEND CTK_QT6_COMPONENTS Widgets OpenGL UiTools) + endif() + if(CTK_LIB_CommandLineModules/Frontend/QtWebKit OR CTK_BUILD_ALL OR CTK_BUILD_ALL_LIBRARIES) + if(TARGET Qt6::WebKitWidgets) + list(APPEND CTK_QT6_COMPONENTS WebKitWidgets) + else() + list(APPEND CTK_QT6_COMPONENTS WebEngineWidgets) + endif() + endif() + if(CTK_LIB_XNAT/Core OR CTK_BUILD_ALL OR CTK_BUILD_ALL_LIBRARIES) + list(APPEND CTK_QT6_COMPONENTS Script) + endif() + find_package(Qt6 COMPONENTS ${CTK_QT6_COMPONENTS} REQUIRED) + + mark_as_superbuild(Qt6_DIR) # Qt 6 + + # XXX Backward compatible way + if(DEFINED CMAKE_PREFIX_PATH) + mark_as_superbuild(CMAKE_PREFIX_PATH) # Qt 6 + endif() - if(CTK_QT_VERSION VERSION_GREATER "4") + elseif(CTK_QT_VERSION VERSION_GREATER "4") cmake_minimum_required(VERSION 2.8.12) - find_package(Qt5 COMPONENTS Core) + find_package(Qt${CTK_QT_VERSION} COMPONENTS Core) set(CTK_QT5_COMPONENTS Core Xml XmlPatterns Concurrent Sql Test Multimedia) if(CTK_ENABLE_Widgets OR CTK_LIB_Widgets OR CTK_LIB_CommandLineModules/Frontend/QtGui OR CTK_BUILD_ALL OR CTK_BUILD_ALL_LIBRARIES) list(APPEND CTK_QT5_COMPONENTS Widgets OpenGL UiTools) endif() if(CTK_LIB_CommandLineModules/Frontend/QtWebKit OR CTK_BUILD_ALL OR CTK_BUILD_ALL_LIBRARIES) - if(TARGET Qt5::WebKitWidgets) + if(TARGET Qt${CTK_QT_VERSION}::WebKitWidgets) list(APPEND CTK_QT5_COMPONENTS WebKitWidgets) else() list(APPEND CTK_QT5_COMPONENTS WebEngineWidgets) @@ -47,7 +73,7 @@ macro(ctkMacroSetupQt) if(CTK_LIB_XNAT/Core OR CTK_BUILD_ALL OR CTK_BUILD_ALL_LIBRARIES) list(APPEND CTK_QT5_COMPONENTS Script) endif() - find_package(Qt5 COMPONENTS ${CTK_QT5_COMPONENTS} REQUIRED) + find_package(Qt${CTK_QT_VERSION} COMPONENTS ${CTK_QT5_COMPONENTS} REQUIRED) mark_as_superbuild(Qt5_DIR) # Qt 5 diff --git a/Libs/CommandLineModules/Core/CMakeLists.txt b/Libs/CommandLineModules/Core/CMakeLists.txt index ce55df9e43..938b372dc6 100644 --- a/Libs/CommandLineModules/Core/CMakeLists.txt +++ b/Libs/CommandLineModules/Core/CMakeLists.txt @@ -79,8 +79,11 @@ set(KIT_resources # The following macro will read the target libraries from the file 'target_libraries.cmake' ctkFunctionGetTargetLibraries(KIT_target_libraries) +if(CTK_QT_VERSION VERSION_EQUAL "5") + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::XmlPatterns) +endif() if(CTK_QT_VERSION VERSION_GREATER "4") - list(APPEND KIT_target_libraries Qt5::XmlPatterns Qt5::Widgets Qt5::Concurrent) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::Widgets Qt${CTK_QT_VERSION}::Concurrent) else() set(QT_USE_QTXMLPATTERNS 1) include(${QT_USE_FILE}) diff --git a/Libs/CommandLineModules/Core/Testing/Cpp/CMakeLists.txt b/Libs/CommandLineModules/Core/Testing/Cpp/CMakeLists.txt index a913bba331..3b5e3ec816 100644 --- a/Libs/CommandLineModules/Core/Testing/Cpp/CMakeLists.txt +++ b/Libs/CommandLineModules/Core/Testing/Cpp/CMakeLists.txt @@ -50,7 +50,7 @@ ctk_add_executable_utf8(${KIT}CppTests ${Tests} ${Tests_SRCS} ${Tests_MOC_CPP} $ target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES}) if(CTK_QT_VERSION VERSION_GREATER "4") - target_link_libraries(${KIT}CppTests Qt5::Test) + target_link_libraries(${KIT}CppTests Qt${CTK_QT_VERSION}::Test) endif() # diff --git a/Libs/CommandLineModules/Frontend/QtGui/CMakeLists.txt b/Libs/CommandLineModules/Frontend/QtGui/CMakeLists.txt index 3ad6dd1e6d..bc2d3e7934 100644 --- a/Libs/CommandLineModules/Frontend/QtGui/CMakeLists.txt +++ b/Libs/CommandLineModules/Frontend/QtGui/CMakeLists.txt @@ -41,9 +41,8 @@ set(KIT_resources # Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake # The following macro will read the target libraries from the file 'target_libraries.cmake' ctkFunctionGetTargetLibraries(KIT_target_libraries) - if(CTK_QT_VERSION VERSION_GREATER "4") - list(APPEND KIT_target_libraries Qt5::UiTools Qt5::Widgets) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::UiTools Qt${CTK_QT_VERSION}::Widgets) else() set(QT_USE_QTUITOOLS 1) include(${QT_USE_FILE}) diff --git a/Libs/CommandLineModules/Frontend/QtGui/Testing/Cpp/CMakeLists.txt b/Libs/CommandLineModules/Frontend/QtGui/Testing/Cpp/CMakeLists.txt index 4fa7d64a26..c927d269dd 100644 --- a/Libs/CommandLineModules/Frontend/QtGui/Testing/Cpp/CMakeLists.txt +++ b/Libs/CommandLineModules/Frontend/QtGui/Testing/Cpp/CMakeLists.txt @@ -53,7 +53,7 @@ ctk_add_executable_utf8(${KIT}CppTests ${Tests} ${Tests_SRCS} ${Tests_MOC_CPP} $ target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES}) if(CTK_QT_VERSION VERSION_GREATER "4") - target_link_libraries(${KIT}CppTests Qt5::Test) + target_link_libraries(${KIT}CppTests Qt${CTK_QT_VERSION}::Test) endif() # diff --git a/Libs/CommandLineModules/Frontend/QtWebKit/CMakeLists.txt b/Libs/CommandLineModules/Frontend/QtWebKit/CMakeLists.txt index 234dd56d4d..dc744bacb4 100644 --- a/Libs/CommandLineModules/Frontend/QtWebKit/CMakeLists.txt +++ b/Libs/CommandLineModules/Frontend/QtWebKit/CMakeLists.txt @@ -37,10 +37,10 @@ set(KIT_resources ctkFunctionGetTargetLibraries(KIT_target_libraries) if(CTK_QT_VERSION VERSION_GREATER "4") - if(TARGET Qt5::WebKitWidgets) - list(APPEND KIT_target_libraries Qt5::WebKitWidgets) + if(TARGET Qt${CTK_QT_VERSION}::WebKitWidgets) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::WebKitWidgets) else() - list(APPEND KIT_target_libraries Qt5::WebEngineWidgets) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::WebEngineWidgets) endif() else() set(QT_USE_QTWEBKIT 1) diff --git a/Libs/CommandLineModules/Testing/Cpp/CMakeLists.txt b/Libs/CommandLineModules/Testing/Cpp/CMakeLists.txt index 58a290ae26..911055ec1c 100644 --- a/Libs/CommandLineModules/Testing/Cpp/CMakeLists.txt +++ b/Libs/CommandLineModules/Testing/Cpp/CMakeLists.txt @@ -97,7 +97,7 @@ target_link_libraries(${KIT}CppTests ${_additional_link_libraries}) add_dependencies(${KIT}CppTests ctkCmdLineTestModules) if(CTK_QT_VERSION VERSION_GREATER "4") - target_link_libraries(${KIT}CppTests Qt5::Gui Qt5::Test) + target_link_libraries(${KIT}CppTests Qt${CTK_QT_VERSION}::Gui Qt${CTK_QT_VERSION}::Test) endif() if(TARGET CTKCommandLineModulesCoreCppTests) diff --git a/Libs/CommandLineModules/Testing/Modules/CMakeLists.txt b/Libs/CommandLineModules/Testing/Modules/CMakeLists.txt index 279ea1556d..77ed15c798 100644 --- a/Libs/CommandLineModules/Testing/Modules/CMakeLists.txt +++ b/Libs/CommandLineModules/Testing/Modules/CMakeLists.txt @@ -15,7 +15,7 @@ function(ctkFunctionCreateCmdLineModule name) if(CTK_QT_VERSION VERSION_LESS "5") target_link_libraries(ctkCmdLineModule${name} CTKCore ${QT_LIBRARIES}) else() - target_link_libraries(ctkCmdLineModule${name} CTKCore Qt5::Widgets) + target_link_libraries(ctkCmdLineModule${name} CTKCore Qt${CTK_QT_VERSION}::Widgets) endif() add_dependencies(ctkCmdLineTestModules ctkCmdLineModule${name}) endfunction() diff --git a/Libs/Core/CMakeLists.txt b/Libs/Core/CMakeLists.txt index 5c6c98b93c..2514d8f951 100644 --- a/Libs/Core/CMakeLists.txt +++ b/Libs/Core/CMakeLists.txt @@ -135,7 +135,9 @@ set(KIT_target_libraries) ctkFunctionGetTargetLibraries(KIT_target_libraries) -if(CTK_QT_VERSION VERSION_GREATER "4") +if(CTK_QT_VERSION VERSION_GREATER "5") + list(APPEND KIT_target_libraries Qt6::Core Qt6::StateMachine Qt6::Core5Compat) +elseif(CTK_QT_VERSION VERSION_GREATER "4") list(APPEND KIT_target_libraries Qt5::Core) endif() @@ -169,6 +171,13 @@ if(CTK_WRAP_PYTHONQT_LIGHT) ) endif() +if( CTK_QT_VERSION VERSION_GREATER_EQUAL "6") +set_property( + SOURCE moc_ctkWorkflow.cpp + PROPERTY COMPILE_DEFINITIONS + CTK_COMPILING_FROM_MOC_CPP + ) +endif() # Testing if(BUILD_TESTING) diff --git a/Libs/Core/Documentation/Snippets/CommandLineParser/main.cpp b/Libs/Core/Documentation/Snippets/CommandLineParser/main.cpp index 1d19fabe95..77d7012a79 100644 --- a/Libs/Core/Documentation/Snippets/CommandLineParser/main.cpp +++ b/Libs/Core/Documentation/Snippets/CommandLineParser/main.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include diff --git a/Libs/Core/Testing/Cpp/CMakeLists.txt b/Libs/Core/Testing/Cpp/CMakeLists.txt index d679dd3687..2ca344c9ed 100644 --- a/Libs/Core/Testing/Cpp/CMakeLists.txt +++ b/Libs/Core/Testing/Cpp/CMakeLists.txt @@ -105,8 +105,8 @@ set(Tests_Helpers_MOC_CPPS set(Tests_Helpers_MOC_CPP) if(CTK_QT_VERSION VERSION_GREATER "4") - qt5_wrap_cpp(Tests_Helpers_MOC_CPP ${Tests_Helpers_MOC_SRCS}) - qt5_generate_mocs(${Tests_Helpers_MOC_CPPS}) + qt_wrap_cpp(Tests_Helpers_MOC_CPP ${Tests_Helpers_MOC_SRCS}) + qt_generate_moc(${Tests_Helpers_MOC_CPPS}) else() QT4_WRAP_CPP(Tests_Helpers_MOC_CPP ${Tests_Helpers_MOC_SRCS}) QT4_GENERATE_MOCS(${Tests_Helpers_MOC_CPPS}) @@ -127,8 +127,8 @@ ctk_add_executable_utf8(${KIT}CppTests ${Tests} ${Tests_Helpers_SRCS} ${Tests_He target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES} CTKDummyPlugin) if(CTK_QT_VERSION VERSION_GREATER "4") - find_package(Qt5 COMPONENTS Test Widgets REQUIRED) - target_link_libraries(${KIT}CppTests Qt5::Test Qt5::Widgets) + find_package(Qt${CTK_QT_VERSION} COMPONENTS Test Widgets REQUIRED) + target_link_libraries(${KIT}CppTests Qt${CTK_QT_VERSION}::Test Qt${CTK_QT_VERSION}::Widgets) endif() if(UNIX AND NOT APPLE) diff --git a/Libs/Core/Testing/Cpp/ctkBooleanMapperTest.cpp b/Libs/Core/Testing/Cpp/ctkBooleanMapperTest.cpp index 097856c50e..9bf65ad205 100644 --- a/Libs/Core/Testing/Cpp/ctkBooleanMapperTest.cpp +++ b/Libs/Core/Testing/Cpp/ctkBooleanMapperTest.cpp @@ -176,4 +176,7 @@ void ctkBooleanMapperTester::testSignals() // ---------------------------------------------------------------------------- CTK_TEST_MAIN(ctkBooleanMapperTest) -#include "moc_ctkBooleanMapperTest.cpp" + +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + #include "moc_ctkBooleanMapperTest.cpp" +#endif \ No newline at end of file diff --git a/Libs/Core/Testing/Cpp/ctkLinearValueProxyTest.cpp b/Libs/Core/Testing/Cpp/ctkLinearValueProxyTest.cpp index c16630d4b8..e45ceb18e2 100644 --- a/Libs/Core/Testing/Cpp/ctkLinearValueProxyTest.cpp +++ b/Libs/Core/Testing/Cpp/ctkLinearValueProxyTest.cpp @@ -506,4 +506,6 @@ void ctkLinearValueProxyTester::testProxyModified_data() // ---------------------------------------------------------------------------- CTK_TEST_MAIN(ctkLinearValueProxyTest) -#include "moc_ctkLinearValueProxyTest.cpp" +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + #include "moc_ctkLinearValueProxyTest.cpp" +#endif diff --git a/Libs/Core/Testing/Cpp/ctkUtilsTest.cpp b/Libs/Core/Testing/Cpp/ctkUtilsTest.cpp index 8a5b57e292..7c5455756a 100644 --- a/Libs/Core/Testing/Cpp/ctkUtilsTest.cpp +++ b/Libs/Core/Testing/Cpp/ctkUtilsTest.cpp @@ -305,5 +305,7 @@ Q_DECLARE_METATYPE (QSet) // ---------------------------------------------------------------------------- CTK_TEST_MAIN(ctkUtilsTest) -#include "moc_ctkUtilsTest.cpp" +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + #include "moc_ctkUtilsTest.cpp" +#endif diff --git a/Libs/Core/ctkCommandLineParser.cpp b/Libs/Core/ctkCommandLineParser.cpp index 22bf017462..f9a1743c52 100644 --- a/Libs/Core/ctkCommandLineParser.cpp +++ b/Libs/Core/ctkCommandLineParser.cpp @@ -31,6 +31,7 @@ // CTK includes #include "ctkCommandLineParser.h" +#include namespace { diff --git a/Libs/Core/ctkErrorLogAbstractModel.cpp b/Libs/Core/ctkErrorLogAbstractModel.cpp index 11e904b423..872c739758 100644 --- a/Libs/Core/ctkErrorLogAbstractModel.cpp +++ b/Libs/Core/ctkErrorLogAbstractModel.cpp @@ -376,10 +376,18 @@ void ctkErrorLogAbstractModel::filterEntry(const ctkErrorLogLevel::LogLevels& lo Q_D(ctkErrorLogAbstractModel); QStringList patterns; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (!this->filterRegExp().pattern().isEmpty()) { patterns << this->filterRegExp().pattern().split("|"); } +#else + if (!this->filterRegularExpression().pattern().isEmpty()) + { + patterns << this->filterRegularExpression().pattern().split("|"); + } + +#endif patterns.removeAll(d->ErrorLogLevel(ctkErrorLogLevel::None)); // foreach(QString s, patterns) @@ -419,7 +427,11 @@ void ctkErrorLogAbstractModel::filterEntry(const ctkErrorLogLevel::LogLevels& lo } bool filterChanged = true; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QStringList currentPatterns = this->filterRegExp().pattern().split("|"); +#else + QStringList currentPatterns = this->filterRegularExpression().pattern().split("|"); +#endif if (currentPatterns.count() == patterns.count()) { foreach(const QString& p, patterns) @@ -428,9 +440,11 @@ void ctkErrorLogAbstractModel::filterEntry(const ctkErrorLogLevel::LogLevels& lo } filterChanged = currentPatterns.count() > 0; } - +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) this->setFilterRegExp(patterns.join("|")); - +#else + this->setFilterRegularExpression(patterns.join("|")); +#endif if (filterChanged) { emit this->logLevelFilterChanged(); @@ -445,10 +459,17 @@ ctkErrorLogLevel::LogLevels ctkErrorLogAbstractModel::logLevelFilter()const Q_ASSERT(QString("LogLevel").compare(logLevelEnum.name()) == 0); ctkErrorLogLevel::LogLevels filter = ctkErrorLogLevel::Unknown; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) foreach(const QString& filterAsString, this->filterRegExp().pattern().split("|")) { filter |= static_cast(logLevelEnum.keyToValue(filterAsString.toLatin1())); } +#else + foreach(const QString& filterAsString, this->filterRegularExpression().pattern().split("|")) + { + filter |= static_cast(logLevelEnum.keyToValue(filterAsString.toLatin1())); + } +#endif return filter; } diff --git a/Libs/Core/ctkUtils.cpp b/Libs/Core/ctkUtils.cpp index 776893398b..3e3801ab30 100644 --- a/Libs/Core/ctkUtils.cpp +++ b/Libs/Core/ctkUtils.cpp @@ -21,7 +21,11 @@ // Qt includes #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#include +#else #include +#endif #include #include @@ -109,17 +113,30 @@ const char *ctkValidWildCard = QStringList ctk::nameFilterToExtensions(const QString& nameFilter) { QRegExp regexp(QString::fromLatin1(ctkNameFilterRegExp)); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + int i = nameFilter.indexOf(regexp); +#else int i = regexp.indexIn(nameFilter); +#endif if (i < 0) { QRegExp isWildCard(QString::fromLatin1(ctkValidWildCard)); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + if (nameFilter.indexOf(isWildCard) >= 0) +#else if (isWildCard.indexIn(nameFilter) >= 0) +#endif { return QStringList(nameFilter); } return QStringList(); } +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + QStringList captured = regexp.namedCaptureGroups(); + QString f = captured.size() >= 3 ? captured[2] : ""; +#else QString f = regexp.cap(2); +#endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) return f.split(QLatin1Char(' '), Qt::SkipEmptyParts); #else @@ -143,12 +160,22 @@ QString ctk::extensionToRegExp(const QString& extension) { // typically *.jpg QRegExp extensionExtractor("\\*\\.(\\w+)"); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + int pos = extension.indexOf(extensionExtractor); +#else int pos = extensionExtractor.indexIn(extension); +#endif if (pos < 0) { return QString(); } - return ".*\\." + extensionExtractor.cap(1) + "?$"; +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + QStringList captured = extensionExtractor.namedCaptureGroups(); + QString cap = captured.size() >= 2 ? captured[1] : ""; +#else + QString cap = extensionExtractor.cap(1); +#endif + return ".*\\." + cap + "?$"; } //----------------------------------------------------------------------------- diff --git a/Libs/Core/ctkUtils.h b/Libs/Core/ctkUtils.h index 5ddd7c774f..605f9e3e1d 100644 --- a/Libs/Core/ctkUtils.h +++ b/Libs/Core/ctkUtils.h @@ -28,6 +28,10 @@ #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#define QRegExp QRegularExpression +#endif + // STD includes #include diff --git a/Libs/Core/ctkWorkflow.h b/Libs/Core/ctkWorkflow.h index 43cbdf83b6..e208192dc3 100644 --- a/Libs/Core/ctkWorkflow.h +++ b/Libs/Core/ctkWorkflow.h @@ -251,5 +251,10 @@ protected Q_SLOTS: Q_DISABLE_COPY(ctkWorkflow); }; +#if defined(CTK_COMPILING_FROM_MOC_CPP) + #include "ctkWorkflowStep.h" +#endif + + #endif diff --git a/Libs/DICOM/Core/CMakeLists.txt b/Libs/DICOM/Core/CMakeLists.txt index d2b7d8c60f..ee14b0109b 100644 --- a/Libs/DICOM/Core/CMakeLists.txt +++ b/Libs/DICOM/Core/CMakeLists.txt @@ -89,7 +89,7 @@ set(KIT_resources ctkFunctionGetTargetLibraries(KIT_target_libraries) if(CTK_QT_VERSION VERSION_GREATER "4") - list(APPEND KIT_target_libraries Qt5::Sql) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::Sql) endif() # create a dcm query/retrieve service config file that points to the build dir diff --git a/Libs/DICOM/Widgets/Testing/Cpp/CMakeLists.txt b/Libs/DICOM/Widgets/Testing/Cpp/CMakeLists.txt index d198b7beb5..9ffe821e07 100644 --- a/Libs/DICOM/Widgets/Testing/Cpp/CMakeLists.txt +++ b/Libs/DICOM/Widgets/Testing/Cpp/CMakeLists.txt @@ -28,9 +28,13 @@ include_directories( set(CTK_QT_TEST_LIBRARY ) -if (CTK_QT_VERSION VERSION_GREATER "4") - find_package(Qt5Test REQUIRED) - set(CTK_QT_TEST_LIBRARY Qt5::Test) +if (CTK_QT_VERSION VERSION_GREATER "5") + find_package(Qt6Test REQUIRED) + set(CTK_QT_TEST_LIBRARY Qt6::Test) + qt_generate_mocs(${Tests_MOC_CPPS}) +elseif (CTK_QT_VERSION VERSION_GREATER "4") + find_package(Qt${CTK_QT_VERSION}Test REQUIRED) + set(CTK_QT_TEST_LIBRARY Qt${CTK_QT_VERSION}::Test) qt5_generate_mocs(${Tests_MOC_CPPS}) else() qt4_generate_mocs(${Tests_MOC_CPPS}) diff --git a/Libs/PluginFramework/CMakeLists.txt b/Libs/PluginFramework/CMakeLists.txt index 06f8db9a4c..75f7c99353 100644 --- a/Libs/PluginFramework/CMakeLists.txt +++ b/Libs/PluginFramework/CMakeLists.txt @@ -158,7 +158,7 @@ set(KIT_resources ctkFunctionGetTargetLibraries(KIT_target_libraries) if(CTK_QT_VERSION VERSION_GREATER "4") - list(APPEND KIT_target_libraries Qt5::Sql Qt5::Concurrent) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::Sql Qt${CTK_QT_VERSION}::Concurrent) endif() # Create a MANIFEST.MF resource for the PluginFramework library, diff --git a/Libs/PluginFramework/Testing/Cpp/CMakeLists.txt b/Libs/PluginFramework/Testing/Cpp/CMakeLists.txt index f3ca856c8c..69713f3b3f 100644 --- a/Libs/PluginFramework/Testing/Cpp/CMakeLists.txt +++ b/Libs/PluginFramework/Testing/Cpp/CMakeLists.txt @@ -21,5 +21,5 @@ add_library(${lib_name} SHARED ${SRCS} ${MY_MOC_CXX}) target_link_libraries(${lib_name} ${fw_lib}) if(CTK_QT_VERSION VERSION_GREATER "4") - target_link_libraries(${lib_name} Qt5::Test) + target_link_libraries(${lib_name} Qt${CTK_QT_VERSION}::Test) endif() diff --git a/Libs/PluginFramework/Testing/FrameworkTestPlugins/app_test/CMakeLists.txt b/Libs/PluginFramework/Testing/FrameworkTestPlugins/app_test/CMakeLists.txt index 1571256fcb..422e399bd6 100644 --- a/Libs/PluginFramework/Testing/FrameworkTestPlugins/app_test/CMakeLists.txt +++ b/Libs/PluginFramework/Testing/FrameworkTestPlugins/app_test/CMakeLists.txt @@ -51,7 +51,7 @@ target_link_libraries(${test_executable} ) if(CTK_QT_VERSION VERSION_GREATER "4") - target_link_libraries(${test_executable} Qt5::Test) + target_link_libraries(${test_executable} Qt{CTK_QT_VERSION}::Test) endif() add_dependencies(${test_executable} ${PROJECT_NAME}) diff --git a/Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginD_test/CMakeLists.txt b/Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginD_test/CMakeLists.txt index 7a519b8dd6..81b94dac75 100644 --- a/Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginD_test/CMakeLists.txt +++ b/Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginD_test/CMakeLists.txt @@ -17,7 +17,7 @@ add_library(${lib_name} SHARED ${PLUGIN_SRCS}) if(CTK_QT_VERSION VERSION_LESS "5") target_link_libraries(${lib_name} ${QT_LIBRARIES}) else() - target_link_libraries(${lib_name} Qt5::Core) + target_link_libraries(${lib_name} Qt${CTK_QT_VERSION}::Core) endif() # Apply properties to the library target. diff --git a/Libs/QtTesting/CMakeLists.txt b/Libs/QtTesting/CMakeLists.txt index 846207740d..eaa553bfc5 100644 --- a/Libs/QtTesting/CMakeLists.txt +++ b/Libs/QtTesting/CMakeLists.txt @@ -151,7 +151,7 @@ set(QtTesting_LIBRARIES QtTesting) ctkFunctionGetTargetLibraries(KIT_target_libraries) if(CTK_QT_VERSION VERSION_GREATER "4") - list(APPEND KIT_target_libraries Qt5::Xml Qt5::XmlPatterns) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::Xml Qt${CTK_QT_VERSION}::XmlPatterns) endif() ctkMacroBuildLib( diff --git a/Libs/Scripting/Python/Core/Testing/Cpp/CMakeLists.txt b/Libs/Scripting/Python/Core/Testing/Cpp/CMakeLists.txt index 31593d59d3..eb395a13e8 100644 --- a/Libs/Scripting/Python/Core/Testing/Cpp/CMakeLists.txt +++ b/Libs/Scripting/Python/Core/Testing/Cpp/CMakeLists.txt @@ -14,10 +14,15 @@ include_directories(${CMAKE_SOURCE_DIR}/Libs/Testing ${CMAKE_CURRENT_BINARY_DIR}) set(CTK_QT_TEST_LIBRARY ) - -if (CTK_QT_VERSION VERSION_GREATER "4") - find_package(Qt5Test REQUIRED) - set(CTK_QT_TEST_LIBRARY Qt5::Test) +if (CTK_QT_VERSION VERSION_GREATER "5") + find_package(Qt6Test REQUIRED) + set(CTK_QT_TEST_LIBRARY Qt6::Test) + QT6_GENERATE_MOCS( + ctkAbstractPythonManagerTest.cpp + ) +elseif (CTK_QT_VERSION VERSION_GREATER "4") + find_package(Qt${CTK_QT_VERSION}Test REQUIRED) + set(CTK_QT_TEST_LIBRARY Qt${CTK_QT_VERSION}::Test) QT5_GENERATE_MOCS( ctkAbstractPythonManagerTest.cpp ) diff --git a/Libs/Widgets/CMakeLists.txt b/Libs/Widgets/CMakeLists.txt index c272782ffb..ddb3981fcd 100644 --- a/Libs/Widgets/CMakeLists.txt +++ b/Libs/Widgets/CMakeLists.txt @@ -353,7 +353,9 @@ set(KIT_resources # The following macro will read the target libraries from the file 'target_libraries.cmake' ctkFunctionGetTargetLibraries(KIT_target_libraries) -if(CTK_QT_VERSION VERSION_GREATER "4") +if(CTK_QT_VERSION VERSION_GREATER "5") + list(APPEND KIT_target_libraries Qt6::Widgets Qt6::Xml Qt6::OpenGL Qt6::OpenGLWidgets) +elseif(CTK_QT_VERSION VERSION_GREATER "4") list(APPEND KIT_target_libraries Qt5::Widgets Qt5::Xml Qt5::OpenGL) endif() @@ -474,3 +476,11 @@ endif() if(BUILD_TESTING) add_subdirectory(Testing) endif() + +if( CTK_QT_VERSION VERSION_GREATER_EQUAL "6") +set_property( + SOURCE moc_ctkSettingsDialog.cpp + PROPERTY COMPILE_DEFINITIONS + CTK_COMPILING_FROM_MOC_CPP + ) +endif() diff --git a/Libs/Widgets/Plugins/ctkPopupWidgetPlugin.cpp b/Libs/Widgets/Plugins/ctkPopupWidgetPlugin.cpp index ea39f9cfe6..a1e607c954 100644 --- a/Libs/Widgets/Plugins/ctkPopupWidgetPlugin.cpp +++ b/Libs/Widgets/Plugins/ctkPopupWidgetPlugin.cpp @@ -33,7 +33,7 @@ QWidget *ctkPopupWidgetPlugin::createWidget(QWidget* widgetParent) { ctkPopupWidget* newWidget = new ctkPopupWidget(widgetParent); // if the widget is a tooltip, it wouldn't accept children - newWidget->setWindowFlags(0); + newWidget->setWindowFlags(Qt::Widget); // if the widget auto hides, it disappear from the workplace and don't allow // children anymore. newWidget->setAutoHide(false); diff --git a/Libs/Widgets/Plugins/ctkWidgetsPlugins.h b/Libs/Widgets/Plugins/ctkWidgetsPlugins.h index de893fdce6..124cea0971 100644 --- a/Libs/Widgets/Plugins/ctkWidgetsPlugins.h +++ b/Libs/Widgets/Plugins/ctkWidgetsPlugins.h @@ -80,10 +80,10 @@ class CTK_WIDGETS_PLUGINS_EXPORT ctkWidgetsPlugins , public QDesignerCustomWidgetCollectionInterface { Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetCollectionInterface) #ifdef HAVE_QT5 Q_PLUGIN_METADATA(IID "org.commontk.Widgets") #endif + Q_INTERFACES(QDesignerCustomWidgetCollectionInterface) public: QList customWidgets() const { diff --git a/Libs/Widgets/Testing/Cpp/CMakeLists.txt b/Libs/Widgets/Testing/Cpp/CMakeLists.txt index a0bc6d6bdf..2a9f5449e3 100644 --- a/Libs/Widgets/Testing/Cpp/CMakeLists.txt +++ b/Libs/Widgets/Testing/Cpp/CMakeLists.txt @@ -250,11 +250,13 @@ endif() ctk_add_executable_utf8(${KIT}CppTests ${Tests} ${Tests_SRCS} ${Tests_MOC_CPP} ${Tests_UI_CPP} ${Tests_RESOURCES_SRCS}) target_link_libraries(${KIT}CppTests ${LIBRARY_NAME}) - if(CTK_QT_VERSION VERSION_GREATER "4") - list(APPEND KIT_target_libraries Qt5::Test) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::Test) if(CTK_USE_QTTESTING) - list(APPEND KIT_target_libraries Qt5::Xml Qt5::XmlPatterns) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::Xml) + if(CTK_QT_VERSION VERSION_EQUAL 5) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::XmlPatterns) + endif() endif() target_link_libraries(${KIT}CppTests ${KIT_target_libraries}) endif() diff --git a/Libs/Widgets/ctkActionsWidget.cpp b/Libs/Widgets/ctkActionsWidget.cpp index f9e5a29274..ef714babfb 100644 --- a/Libs/Widgets/ctkActionsWidget.cpp +++ b/Libs/Widgets/ctkActionsWidget.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include + // CTK includes #include "ctkActionsWidget.h" diff --git a/Libs/Widgets/ctkBasePopupWidget.cpp b/Libs/Widgets/ctkBasePopupWidget.cpp index 8348161c7e..0962eea117 100644 --- a/Libs/Widgets/ctkBasePopupWidget.cpp +++ b/Libs/Widgets/ctkBasePopupWidget.cpp @@ -21,7 +21,9 @@ // Qt includes #include #include +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #include +#endif #include #include #include diff --git a/Libs/Widgets/ctkCheckableComboBox.cpp b/Libs/Widgets/ctkCheckableComboBox.cpp index 75ee9ca126..6d85c0a2de 100644 --- a/Libs/Widgets/ctkCheckableComboBox.cpp +++ b/Libs/Widgets/ctkCheckableComboBox.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/Libs/Widgets/ctkCheckablePushButton.cpp b/Libs/Widgets/ctkCheckablePushButton.cpp index 50f29d02da..9c575f5e42 100644 --- a/Libs/Widgets/ctkCheckablePushButton.cpp +++ b/Libs/Widgets/ctkCheckablePushButton.cpp @@ -21,7 +21,6 @@ // Qt includes #include #include -#include #include #include #include @@ -87,8 +86,11 @@ QStyleOptionButton ctkCheckablePushButtonPrivate::drawIcon(QPainter* p) Q_Q(ctkCheckablePushButton); QStyleOptionButton indicatorOpt; - +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + indicatorOpt.initFrom(q); +#else indicatorOpt.init(q); +#endif if (!this->CheckBoxUserCheckable) { indicatorOpt.state &= ~QStyle::State_Enabled; diff --git a/Libs/Widgets/ctkCollapsibleButton.cpp b/Libs/Widgets/ctkCollapsibleButton.cpp index d9218e3468..7439f2c7d2 100644 --- a/Libs/Widgets/ctkCollapsibleButton.cpp +++ b/Libs/Widgets/ctkCollapsibleButton.cpp @@ -30,7 +30,9 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) #include +#endif // CTK includes #include "ctkCollapsibleButton.h" @@ -450,8 +452,13 @@ QSize ctkCollapsibleButton::buttonSizeHint()const } h = qMax(h, sz.height()); //opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height + #if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) QSize buttonSize = (style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), this). expandedTo(QApplication::globalStrut())); + #else + QSize buttonSize = style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), this); + #endif + return buttonSize; } @@ -558,7 +565,11 @@ void ctkCollapsibleButton::paintEvent(QPaintEvent * _event) int buttonMargin = this->style()->pixelMetric(QStyle::PM_ButtonMargin, &opt, this); // Draw Indicator QStyleOption indicatorOpt; +#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) indicatorOpt.init(this); +#else + indicatorOpt.initFrom(this); +#endif if (d->IndicatorAlignment & Qt::AlignLeft) { indicatorOpt.rect = QRect((buttonHeight - indicatorSize.width()) / 2, @@ -652,7 +663,11 @@ void ctkCollapsibleButton::paintEvent(QPaintEvent * _event) #else QStyleOptionFrame fopt; #endif - fopt.init(this); + #if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) + fopt.init(this); + #else + fopt.initFrom(this); + #endif // HACK: on some styles, the frame doesn't exactly touch the button. // this is because the button has some kind of extra border. #if QT_VERSION < QT_VERSION_CHECK(5,0,0) diff --git a/Libs/Widgets/ctkColorPickerButton.cpp b/Libs/Widgets/ctkColorPickerButton.cpp index 98ace0aa87..32f00719f1 100644 --- a/Libs/Widgets/ctkColorPickerButton.cpp +++ b/Libs/Widgets/ctkColorPickerButton.cpp @@ -297,17 +297,24 @@ QSize ctkColorPickerButton::sizeHint()const opt.iconSize = QSize(iconSize, iconSize); opt.rect.setSize(opt.iconSize); // PM_MenuButtonIndicator depends on the height d->CachedSizeHint = this->style()->sizeFromContents( - QStyle::CT_ToolButton, &opt, opt.iconSize, this). - expandedTo(QApplication::globalStrut()); + QStyle::CT_ToolButton, &opt, opt.iconSize, this) + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + .expandedTo(QApplication::globalStrut()) + #endif + ; } else { pushButtonOpt.icon = d->Icon; pushButtonOpt.iconSize = QSize(iconSize, iconSize); pushButtonOpt.rect.setSize(pushButtonOpt.iconSize); // PM_MenuButtonIndicator depends on the height - d->CachedSizeHint = (style()->sizeFromContents( - QStyle::CT_PushButton, &pushButtonOpt, pushButtonOpt.iconSize, this). - expandedTo(QApplication::globalStrut())); + d->CachedSizeHint = style()->sizeFromContents( + QStyle::CT_PushButton, &pushButtonOpt, pushButtonOpt.iconSize, this) + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + .expandedTo(QApplication::globalStrut()) + #endif + ; + } return d->CachedSizeHint; } diff --git a/Libs/Widgets/ctkComboBox.cpp b/Libs/Widgets/ctkComboBox.cpp index 21192f59c0..b53f06fb05 100644 --- a/Libs/Widgets/ctkComboBox.cpp +++ b/Libs/Widgets/ctkComboBox.cpp @@ -65,7 +65,11 @@ QSize ctkComboBoxPrivate::recomputeSizeHint(QSize &sh) const Q_Q(const ctkComboBox); if (sh.isValid()) { +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + return sh; +#else return sh.expandedTo(QApplication::globalStrut()); +#endif } bool hasIcon = false; @@ -151,7 +155,11 @@ QSize ctkComboBoxPrivate::recomputeSizeHint(QSize &sh) const QStyleOptionComboBox opt; this->initStyleOption(&opt); sh = q->style()->sizeFromContents(QStyle::CT_ComboBox, &opt, sh, q); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + return sh; +#else return sh.expandedTo(QApplication::globalStrut()); +#endif } // ------------------------------------------------------------------------- diff --git a/Libs/Widgets/ctkCompleter.cpp b/Libs/Widgets/ctkCompleter.cpp index 86f8030474..89e2bc6a9c 100644 --- a/Libs/Widgets/ctkCompleter.cpp +++ b/Libs/Widgets/ctkCompleter.cpp @@ -22,7 +22,9 @@ #include #include #include - +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#define QRegExp QRegularExpression +#endif // CTK includes #include "ctkCompleter.h" @@ -87,9 +89,14 @@ QStringList ctkCompleterPrivate::splitPath(const QString& s) case ctkCompleter::FilterWordStartsWith: { this->updateSortFilterProxyModel(); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + QRegularExpression regexp = QRegularExpression(QRegularExpression::escape(s), QRegularExpression::PatternOption::CaseInsensitiveOption); + this->SortFilterProxyModel->setFilterRegularExpression(regexp); +#else QRegExp regexp = QRegExp(QRegExp::escape(s)); regexp.setCaseSensitivity(q->caseSensitivity()); this->SortFilterProxyModel->setFilterRegExp(regexp); +#endif paths = QStringList(); break; } diff --git a/Libs/Widgets/ctkConsole.cpp b/Libs/Widgets/ctkConsole.cpp index 589d93bb56..63c6ff3d56 100644 --- a/Libs/Widgets/ctkConsole.cpp +++ b/Libs/Widgets/ctkConsole.cpp @@ -71,6 +71,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "ctkConsole_p.h" #include "ctkPimpl.h" +//QT6 compatibility +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#include +#define QRegExp QRegularExpression +#endif //----------------------------------------------------------------------------- // ctkConsoleCompleter methods @@ -152,7 +157,9 @@ void ctkConsolePrivate::init() this->RunFileButton->setVisible(false); QVBoxLayout * layout = new QVBoxLayout(q); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) layout->setMargin(0); +#endif layout->setSpacing(0); layout->addWidget(this); layout->addWidget(this->RunFileButton); @@ -323,30 +330,30 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e) } } - QTextCursor textCursor = this->textCursor(); + QTextCursor text_cursor = this->textCursor(); // Set to true if there's a current selection - const bool selection = (textCursor.anchor() != textCursor.position()); + const bool selection = text_cursor.anchor() != text_cursor.position(); // Set to true if the cursor overlaps the history area - bool history_area = this->isCursorInHistoryArea(); + const bool history_area = this->isCursorInHistoryArea(); // The message output area is defined just under the command line // and it can display all messages catch during we autocomplete, etc. // Set to true if the cursor overlaps the message output area - bool message_output_area = this->isCursorInMessageOutputArea(); + const bool message_output_area = this->isCursorInMessageOutputArea(); if (e->key() == Qt::Key_Escape) { if (selection) { // if a selection is active then Esc removes it - textCursor.setPosition(textCursor.position()); - this->setTextCursor(textCursor); + text_cursor.setPosition(text_cursor.position()); + this->setTextCursor(text_cursor); } else if (history_area || message_output_area) { // if not in the interactive area then Esc moves back to the end of the interactive area - textCursor.setPosition(this->commandEnd()); - this->setTextCursor(textCursor); + text_cursor.setPosition(this->commandEnd()); + this->setTextCursor(text_cursor); } else { @@ -390,8 +397,8 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e) { if(history_area || message_output_area) { - textCursor.setPosition(this->commandEnd()); - this->setTextCursor(textCursor); + text_cursor.setPosition(this->commandEnd()); + this->setTextCursor(text_cursor); } this->paste(); this->updateCommandBuffer(); @@ -427,10 +434,8 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e) && e->key() != Qt::Key_Alt && e->key() != Qt::Key_Shift) { - textCursor.setPosition(this->commandEnd()); - this->setTextCursor(textCursor); - message_output_area = false; - history_area = false; + text_cursor.setPosition(this->commandEnd()); + this->setTextCursor(text_cursor); } // Start of line should be the start of interactive area @@ -438,15 +443,15 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e) QTextCursor::MoveMode moveMode = QTextCursor::MoveAnchor; if(isMoveLeftWithinLine(e, moveOperation, moveMode)) { - textCursor.movePosition(moveOperation, moveMode); - if (textCursor.position() >= this->InteractivePosition) + text_cursor.movePosition(moveOperation, moveMode); + if (text_cursor.position() >= this->InteractivePosition) { this->Superclass::keyPressEvent(e); } else { - textCursor.setPosition(this->InteractivePosition, moveMode); - this->setTextCursor(textCursor); + text_cursor.setPosition(this->InteractivePosition, moveMode); + this->setTextCursor(text_cursor); e->accept(); } this->updateCompleterIfVisible(); @@ -458,15 +463,15 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e) moveMode = QTextCursor::MoveAnchor; if(isMoveRighttWithinLine(e, moveOperation, moveMode)) { - textCursor.movePosition(moveOperation, moveMode); - if (textCursor.position() <= this->commandEnd()) + text_cursor.movePosition(moveOperation, moveMode); + if (text_cursor.position() <= this->commandEnd()) { this->Superclass::keyPressEvent(e); } else { - textCursor.setPosition(this->commandEnd(), moveMode); - this->setTextCursor(textCursor); + text_cursor.setPosition(this->commandEnd(), moveMode); + this->setTextCursor(text_cursor); e->accept(); } this->updateCompleterIfVisible(); @@ -479,8 +484,8 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e) // Can delete only if we are not at the end of the command line. // There is an exception if something (in the interactive area only) is selected, // because it will erase the text selected instead. - if (textCursor.position() < this->commandEnd() - || (textCursor.position() <= this->commandEnd() + if (text_cursor.position() < this->commandEnd() + || (text_cursor.position() <= this->commandEnd() && selection && !message_output_area && !history_area)) { this->Superclass::keyPressEvent(e); @@ -497,8 +502,8 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e) // Can delete with backspace only if the cursor is after the InteractivePosition. // There is an exception if something (in the interactive area only) is selected, // because it will erase the text selected instead. - if (textCursor.position() > this->InteractivePosition - || (textCursor.position() >= this->InteractivePosition + if (text_cursor.position() > this->InteractivePosition + || (text_cursor.position() >= this->InteractivePosition && selection && !message_output_area && !history_area)) { this->Superclass::keyPressEvent(e); @@ -511,7 +516,7 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e) if (e == QKeySequence::DeleteStartOfWord) { e->accept(); - if (textCursor.position() > this->InteractivePosition) + if (text_cursor.position() > this->InteractivePosition) { this->Superclass::keyPressEvent(e); this->updateCommandBuffer(); @@ -548,8 +553,8 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e) if (e == QKeySequence::InsertParagraphSeparator) { e->accept(); - textCursor.setPosition(this->documentEnd()); - this->setTextCursor(textCursor); + text_cursor.setPosition(this->documentEnd()); + this->setTextCursor(text_cursor); if (this->InputEventLoop.isNull()) { this->internalExecuteCommand(); @@ -561,7 +566,7 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e) return; } - if (this->CompleterShortcuts.contains(e->key() + e->modifiers())) + if (this->CompleterShortcuts.contains(e->key() + static_cast(e->modifiers()))) { e->accept(); this->updateCompleter(); @@ -696,14 +701,14 @@ void ctkConsolePrivate::updateCompleter() { // Get the text between the current cursor position // and the start of the line - QTextCursor textCursor = this->textCursor(); - while (!textCursor.selectedText().contains(q_ptr->ps1())) + QTextCursor text_cursor = this->textCursor(); + while (!text_cursor.selectedText().contains(q_ptr->ps1())) { - textCursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor); + text_cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor); } // search through the text the multiline statement symbol "... " + 1 char (go to the line char) - QString commandText = textCursor.selectedText(); + QString commandText = text_cursor.selectedText(); int pos_Ps2 = commandText.indexOf(q_ptr->ps2())-1; while (pos_Ps2 > -1) { @@ -730,9 +735,9 @@ void ctkConsolePrivate::updateCompleter() int savedCursorPosition = this->textCursor().position(); //move the cursor at the end in case of a message displayed - textCursor = this->textCursor(); - textCursor.setPosition(this->documentEnd()); - this->setTextCursor(textCursor); + QTextCursor tc = this->textCursor(); + tc.setPosition(this->documentEnd()); + this->setTextCursor(tc); // Save color of displayed message QColor savedOutputTextColor = this->OutputTextColor; QColor savedErrorTextColor = this->ErrorTextColor; @@ -749,7 +754,7 @@ void ctkConsolePrivate::updateCompleter() // Restore positions this->InteractivePosition = savedInteractivePosition; - textCursor = this->textCursor(); + QTextCursor textCursor = this->textCursor(); textCursor.setPosition(savedCursorPosition); this->setTextCursor(textCursor); @@ -759,9 +764,9 @@ void ctkConsolePrivate::updateCompleter() { // Get a QRect for the cursor at the start of the // current word and then translate it down 8 pixels. - textCursor = this->textCursor(); - textCursor.movePosition(QTextCursor::StartOfWord); - QRect cr = this->cursorRect(textCursor); + text_cursor = this->textCursor(); + text_cursor.movePosition(QTextCursor::StartOfWord); + QRect cr = this->cursorRect(text_cursor); cr.translate(0,8); cr.setWidth(this->Completer->popup()->sizeHintForColumn(0) + this->Completer->popup()->verticalScrollBar()->sizeHint().width()); @@ -842,12 +847,22 @@ void ctkConsolePrivate::internalExecuteCommand() if (this->EditorHints & ctkConsole::AutomaticIndentation) { QRegExp regExp("^(\\s+)"); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + if( command.indexOf(regExp) >= 0) + { + QStringList captured = regExp.namedCaptureGroups(); + if (captured.size() >= 2) + { + indent = captured[1]; + } + } +#else if (regExp.indexIn(command) != -1) { indent = regExp.cap(1); } +#endif } - // Give a chance for log messages to appear before displaying the new prompt. qApp->processEvents(QEventLoop::ExcludeUserInputEvents); @@ -866,9 +881,9 @@ void ctkConsolePrivate::processInput() this->commandBuffer() = command; // Update buffer } - QTextCursor textCursor = this->textCursor(); - textCursor.movePosition(QTextCursor::End); - textCursor.insertText("\n"); + QTextCursor c(this->document()); + c.movePosition(QTextCursor::End); + c.insertText("\n"); this->InteractivePosition = this->documentEnd(); @@ -878,9 +893,8 @@ void ctkConsolePrivate::processInput() //----------------------------------------------------------------------------- void ctkConsolePrivate::printString(const QString& text) { - QTextCursor textCursor = this->textCursor(); - textCursor.movePosition(QTextCursor::End); - textCursor.insertText(text); + this->textCursor().movePosition(QTextCursor::End); + this->textCursor().insertText(text); } //----------------------------------------------------------------------------- @@ -914,14 +928,14 @@ void ctkConsolePrivate::promptForInput(const QString& indent) //----------------------------------------------------------------------------- void ctkConsolePrivate::prompt(const QString& text) { - QTextCursor textCursor = this->textCursor(); + QTextCursor text_cursor = this->textCursor(); // If the cursor is currently on a clean line, do nothing, otherwise we move // the cursor to a new line before showing the prompt. - textCursor.movePosition(QTextCursor::StartOfLine); - int startpos = textCursor.position(); - textCursor.movePosition(QTextCursor::EndOfLine); - int endpos = textCursor.position(); + text_cursor.movePosition(QTextCursor::StartOfLine); + int startpos = text_cursor.position(); + text_cursor.movePosition(QTextCursor::EndOfLine); + int endpos = text_cursor.position(); if (endpos != startpos) { this->textCursor().insertText("\n"); @@ -945,53 +959,51 @@ void ctkConsolePrivate::printWelcomeMessage() void ctkConsolePrivate::insertCompletion(const QString& completion) { Q_Q(ctkConsole); - QTextCursor textCursor = this->textCursor(); - textCursor.setPosition(this->commandEnd()); + QTextCursor tc = this->textCursor(); // save the initial cursor position QTextCursor endOfCompletion = this->textCursor(); - endOfCompletion.setPosition(this->commandEnd()); + endOfCompletion.setPosition(tc.position()); // Select the previous character - textCursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor); - QString charBeforeCompletion = textCursor.selectedText(); - if (charBeforeCompletion == ".") + tc.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor); + if (tc.selectedText()==".") { - textCursor.insertText(QString(".") + completion); + tc.insertText(QString(".") + completion); } else { //can't more autocomplete when cursor right after '(' or ')' - if (charBeforeCompletion == ")" || charBeforeCompletion == "(") + if (tc.selectedText()==")" || tc.selectedText()=="(") { return; } - textCursor.clearSelection(); - textCursor.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor); + tc.clearSelection(); + tc.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor); if (insertCompletionMethod) { - textCursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); + tc.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); } else { - textCursor.setPosition(endOfCompletion.position(), QTextCursor::KeepAnchor); + tc.setPosition(endOfCompletion.position(), QTextCursor::KeepAnchor); } - textCursor.insertText(completion); - endOfCompletion.setPosition(textCursor.position()); - this->setTextCursor(textCursor); + tc.insertText(completion); + endOfCompletion.setPosition(tc.position()); + this->setTextCursor(tc); } // Get back the whole command line to apply a cursor offset // (moving cursor between parenthsesis if the completion is // a callable object with more than the self argument) // StartOfBlock don't catch the whole command line if multi-line statement - textCursor.movePosition(QTextCursor::StartOfBlock,QTextCursor::KeepAnchor); - QString shellLine = textCursor.selectedText(); + tc.movePosition(QTextCursor::StartOfBlock,QTextCursor::KeepAnchor); + QString shellLine = tc.selectedText(); shellLine.replace(q->ps1(), ""); shellLine.replace(q->ps2(), ""); - textCursor.setPosition(endOfCompletion.position()); - this->setTextCursor(textCursor); + tc.setPosition(endOfCompletion.position()); + this->setTextCursor(tc); int cursorOffset = this->Completer->cursorOffset(shellLine); - textCursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, cursorOffset); - this->setTextCursor(textCursor); + tc.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, cursorOffset); + this->setTextCursor(tc); this->updateCommandBuffer(); } @@ -1065,12 +1077,8 @@ void ctkConsolePrivate::pasteText(const QString& text) && text.trimmed().contains("\n")) { // Execute at once - q->printMessage("\n" + text.trimmed(), this->StdinTextColor); + q->printMessage("\n" + text.trimmed() + "\n", this->StdinTextColor); q->executeString(text); - - // Give a chance for log messages to appear before displaying the new prompt. - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - this->promptForInput(); return; } @@ -1173,10 +1181,10 @@ void ctkConsole::setShellFont(const QFont& font) int savedPosition = d->textCursor().position(); d->selectAll(); d->setCurrentFont(font); - QTextCursor textCursor = d->textCursor(); - textCursor.clearSelection(); - textCursor.setPosition(savedPosition); - d->setTextCursor(textCursor); + QTextCursor tc = d->textCursor(); + tc.clearSelection(); + tc.setPosition(savedPosition); + d->setTextCursor(tc); } //----------------------------------------------------------------------------- @@ -1266,10 +1274,10 @@ int ctkConsole::cursorColumn() const int ctkConsole::cursorLine() const { Q_D(const ctkConsole); - QTextCursor textCursor = d->textCursor(); - textCursor.movePosition(QTextCursor::StartOfLine); + QTextCursor cursor = d->textCursor(); + cursor.movePosition(QTextCursor::StartOfLine); int lines = 1; - QTextBlock block = textCursor.block().previous(); + QTextBlock block = cursor.block().previous(); while(block.isValid()) { lines += block.lineCount(); @@ -1384,9 +1392,6 @@ void ctkConsole::runFile(const QString& filePath) this->printMessage("\n" + commands.trimmed() + "\n", d->StdinTextColor); this->executeString(commands); - // Give a chance for log messages to appear before displaying the new prompt. - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - // Display a new command prompt and allow the user to resume typing the command. d->promptForInput(); d->replaceCommandBuffer(savedCommand); @@ -1432,15 +1437,10 @@ void ctkConsole::printMessage(const QString& message, const QColor& color) { Q_D(ctkConsole); - // Jump to the end and print text with the selected color - - QTextCursor textCursor = d->textCursor(); - textCursor.movePosition(QTextCursor::End); - QTextCharFormat format = this->getFormat(); format.setForeground(color); - - textCursor.insertText(message, format); + this->setFormat(format); + d->printString(message); } //---------------------------------------------------------------------------- diff --git a/Libs/Widgets/ctkDoubleSpinBox.cpp b/Libs/Widgets/ctkDoubleSpinBox.cpp index a2f6afd8f5..19b4034171 100644 --- a/Libs/Widgets/ctkDoubleSpinBox.cpp +++ b/Libs/Widgets/ctkDoubleSpinBox.cpp @@ -398,13 +398,18 @@ ::validateAndInterpret(QString &input, int &pos, // could be because of group separators: if (!ok && state == QValidator::Acceptable) { - if (q->locale().groupSeparator().isPrint()) + #if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) + QChar groupSeparator(q->locale().groupSeparator()[0]); + #else + QChar groupSeparator(q->locale().groupSeparator()); + #endif + if (groupSeparator.isPrint()) { int start = (dec == -1 ? text.size() : dec)- 1; int lastGroupSeparator = start; for (int digit = start; digit >= 0; --digit) { - if (text.at(digit) == q->locale().groupSeparator()) + if (text.at(digit) == groupSeparator) { if (digit != lastGroupSeparator - 3) { @@ -1102,7 +1107,10 @@ QSize ctkDoubleSpinBox::sizeHint() const opt.rect = this->rect(); d->CachedSizeHint = this->style()->sizeFromContents( QStyle::CT_SpinBox, &opt, newSizeHint, this) - .expandedTo(QApplication::globalStrut()); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + .expandedTo(QApplication::globalStrut()) + #endif + ; return d->CachedSizeHint; } @@ -1158,7 +1166,10 @@ QSize ctkDoubleSpinBox::minimumSizeHint() const opt.rect = this->rect(); d->CachedMinimumSizeHint = this->style()->sizeFromContents( QStyle::CT_SpinBox, &opt, newSizeHint, this) - .expandedTo(QApplication::globalStrut()); + #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + .expandedTo(QApplication::globalStrut()) + #endif + ; return d->CachedMinimumSizeHint; } diff --git a/Libs/Widgets/ctkExpandButton.cpp b/Libs/Widgets/ctkExpandButton.cpp index 7eea69c9cd..cf33c306b1 100644 --- a/Libs/Widgets/ctkExpandButton.cpp +++ b/Libs/Widgets/ctkExpandButton.cpp @@ -102,7 +102,11 @@ void ctkExpandButton::setOrientation(Qt::Orientation newOrientation) { Q_D(ctkExpandButton); QStyleOption opt; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) opt.init(this); +#else + opt.initFrom(this); +#endif if(newOrientation == Qt::Horizontal) { d->defaultPixmap = this->style()->standardPixmap( diff --git a/Libs/Widgets/ctkMenuButton.cpp b/Libs/Widgets/ctkMenuButton.cpp index 2216ec3604..33edcd1d30 100644 --- a/Libs/Widgets/ctkMenuButton.cpp +++ b/Libs/Widgets/ctkMenuButton.cpp @@ -21,7 +21,6 @@ // Qt includes #include #include -#include #include #include #include @@ -159,7 +158,11 @@ void ctkMenuButton::paintEvent(QPaintEvent * _event) QPoint(downArrowRect.left(), downArrowRect.bottom() - borderSize)); // Draw arrow QStyleOption indicatorOpt; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) indicatorOpt.init(this); +#else + indicatorOpt.initFrom(this); +#endif indicatorOpt.rect = downArrowRect.adjusted(borderSize, borderSize, -borderSize, -borderSize); painter.drawPrimitive(QStyle::PE_IndicatorArrowDown, indicatorOpt); diff --git a/Libs/Widgets/ctkPathLineEdit.cpp b/Libs/Widgets/ctkPathLineEdit.cpp index af0d347f19..1462eabdc5 100644 --- a/Libs/Widgets/ctkPathLineEdit.cpp +++ b/Libs/Widgets/ctkPathLineEdit.cpp @@ -29,7 +29,12 @@ #include #include #include +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #include +#else +#include +#define QRegExpValidator QRegularExpressionValidator +#endif #include #include #include @@ -462,7 +467,11 @@ QSize ctkPathLineEditPrivate::recomputeSizeHint(QSize& sh)const sh.rwidth() = frame + textWidth + browseWidth; sh.rheight() = height; } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) return sh.expandedTo(QApplication::globalStrut()); +#else + return sh; +#endif } //----------------------------------------------------------------------------- @@ -471,7 +480,11 @@ void ctkPathLineEditPrivate::updateFilter() Q_Q(ctkPathLineEdit); this->Completer->setShowFiles(this->Filters & QDir::Files); this->Completer->setNameFilters(ctk::nameFiltersToExtensions(this->NameFilters)); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) this->Validator->setRegExp(ctk::nameFiltersToRegExp(this->NameFilters)); +#else + this->Validator->setRegularExpression(ctk::nameFiltersToRegExp(this->NameFilters)); +#endif } //----------------------------------------------------------------------------- diff --git a/Libs/Widgets/ctkPathListButtonsWidget.cpp b/Libs/Widgets/ctkPathListButtonsWidget.cpp index be5f240b2c..502c09f89f 100644 --- a/Libs/Widgets/ctkPathListButtonsWidget.cpp +++ b/Libs/Widgets/ctkPathListButtonsWidget.cpp @@ -157,7 +157,11 @@ QStringList ctkPathListButtonsWidgetPrivate::openAddFilesDialog(bool multiple) } QFileDialog fileDialog(q, caption); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) fileDialog.setReadOnly(true); +#else + fileDialog.setOption(QFileDialog::Option::ReadOnly, true); +#endif if (multiple) { diff --git a/Libs/Widgets/ctkPixmapIconEngine.cpp b/Libs/Widgets/ctkPixmapIconEngine.cpp index cb050f5e71..c605164363 100644 --- a/Libs/Widgets/ctkPixmapIconEngine.cpp +++ b/Libs/Widgets/ctkPixmapIconEngine.cpp @@ -335,6 +335,9 @@ bool ctkPixmapIconEngine::write(QDataStream &out) const void ctkPixmapIconEngine::virtual_hook(int id, void *data) { +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + return QIconEngine::virtual_hook(id, data); +#else switch (id) { #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) case QIconEngine::AvailableSizesHook: { @@ -364,4 +367,5 @@ void ctkPixmapIconEngine::virtual_hook(int id, void *data) QIconEngineV2::virtual_hook(id, data); #endif } +#endif } diff --git a/Libs/Widgets/ctkPopupWidget.cpp b/Libs/Widgets/ctkPopupWidget.cpp index 1015547f12..b01662549f 100644 --- a/Libs/Widgets/ctkPopupWidget.cpp +++ b/Libs/Widgets/ctkPopupWidget.cpp @@ -20,7 +20,9 @@ // Qt includes #include +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #include +#endif #include #include #include @@ -416,7 +418,11 @@ void ctkPopupWidget::leaveEvent(QEvent* event) } // -------------------------------------------------------------------------- +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +void ctkPopupWidget::enterEvent(QEnterEvent* event) +#else void ctkPopupWidget::enterEvent(QEvent* event) +#endif { Q_D(ctkPopupWidget); QTimer::singleShot(d->ShowDelay, this, SLOT(updatePopup())); diff --git a/Libs/Widgets/ctkPopupWidget.h b/Libs/Widgets/ctkPopupWidget.h index 7922828f12..c5f7f25cf1 100644 --- a/Libs/Widgets/ctkPopupWidget.h +++ b/Libs/Widgets/ctkPopupWidget.h @@ -113,7 +113,11 @@ public Q_SLOTS: protected: virtual void leaveEvent(QEvent* event); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + virtual void enterEvent(QEnterEvent* event); +#else virtual void enterEvent(QEvent* event); +#endif virtual bool eventFilter(QObject* obj, QEvent* event); /// Widget the popup is attached to. It opens right under \a baseWidget diff --git a/Libs/Widgets/ctkPushButton.cpp b/Libs/Widgets/ctkPushButton.cpp index 82956dc49a..4c5179c536 100644 --- a/Libs/Widgets/ctkPushButton.cpp +++ b/Libs/Widgets/ctkPushButton.cpp @@ -59,7 +59,6 @@ QRect ctkPushButtonPrivate::iconRect()const QSize iconSize = q->iconSize(); int buttonHeight = opt.rect.height(); - int buttonWidth = opt.rect.width(); uint tf = this->ButtonTextAlignment; if (q->style()->styleHint(QStyle::SH_UnderlineShortcut, &opt, q)) { @@ -150,8 +149,11 @@ QSize ctkPushButtonPrivate::buttonSizeHint(bool computeMinimum)const } h = qMax(h, sz.height()); //opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height - QSize buttonSize = (q->style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), q). - expandedTo(QApplication::globalStrut())); + QSize buttonSize = q->style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), q) +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + .expandedTo(QApplication::globalStrut()) +#endif + ; return buttonSize; } @@ -160,7 +162,11 @@ QStyleOptionButton ctkPushButtonPrivate::drawIcon(QPainter* p) { Q_Q(ctkPushButton); QStyleOptionButton iconOpt; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) iconOpt.init(q); +#else + iconOpt.initFrom(q); +#endif iconOpt.rect = this->iconRect(); if (q->icon().isNull()) { diff --git a/Libs/Widgets/ctkQImageView.cpp b/Libs/Widgets/ctkQImageView.cpp index fb2b907124..0798b1c9d2 100644 --- a/Libs/Widgets/ctkQImageView.cpp +++ b/Libs/Widgets/ctkQImageView.cpp @@ -738,7 +738,11 @@ void ctkQImageView::mousePressEvent( QMouseEvent * event ) d->MouseLastIntensityLevel = this->intensityLevel(); break; } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) case Qt::MidButton: +#else + case Qt::MiddleButton: +#endif { d->MouseMiddleDragging = true; d->MouseLastX = event->x(); diff --git a/Libs/Widgets/ctkRangeSlider.cpp b/Libs/Widgets/ctkRangeSlider.cpp index a20a99b242..48fd0b9038 100644 --- a/Libs/Widgets/ctkRangeSlider.cpp +++ b/Libs/Widgets/ctkRangeSlider.cpp @@ -111,7 +111,7 @@ ctkRangeSliderPrivate::ctkRangeSliderPrivate(ctkRangeSlider& object) this->m_SubclassClickOffset = 0; this->m_SubclassPosition = 0; this->m_SubclassWidth = 0.0; - this->m_SelectedHandles = 0; + this->m_SelectedHandles = ctkRangeSliderPrivate::Handles(); // initialize QFlags with no flags this->m_SymmetricMoves = false; } @@ -773,7 +773,7 @@ void ctkRangeSlider::mouseReleaseEvent(QMouseEvent* mouseEvent) this->QSlider::mouseReleaseEvent(mouseEvent); setSliderDown(false); - d->m_SelectedHandles = 0; + d->m_SelectedHandles = ctkRangeSliderPrivate::Handles(); // initialize QFlags with no flags set this->update(); } diff --git a/Libs/Widgets/ctkScreenshotDialog.cpp b/Libs/Widgets/ctkScreenshotDialog.cpp index 6838bf77b3..3c90a4e74d 100644 --- a/Libs/Widgets/ctkScreenshotDialog.cpp +++ b/Libs/Widgets/ctkScreenshotDialog.cpp @@ -169,7 +169,7 @@ void ctkScreenshotDialogPrivate::lockAspectRatio(bool lock) } else { - QString message = QString("Height of widget: ") + curSize.height() +\ + QString message = QString("Height of widget: ") + QString::number(curSize.height()) +\ QString(" is invalid. Check widget dimensions. Using default aspect\ ratio (1.0)."); QMessageBox::warning(q, "Invalid widget dimensions", message, @@ -191,7 +191,7 @@ void ctkScreenshotDialogPrivate::onWidthEdited() } else { - QString message = QString("Aspect ratio: ") + this->AspectRatio +\ + QString message = QString("Aspect ratio: ") + QString::number(this->AspectRatio) +\ QString(" is invalid. Check widget dimensions."); QMessageBox::warning(q, "Invalid aspect ratio", message, QMessageBox::Ok); } diff --git a/Libs/Widgets/ctkSettings.cpp b/Libs/Widgets/ctkSettings.cpp index 67f76598fa..d605118713 100644 --- a/Libs/Widgets/ctkSettings.cpp +++ b/Libs/Widgets/ctkSettings.cpp @@ -53,8 +53,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Qt includes #include #include +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #include - +#else +#include +#include +#endif //----------------------------------------------------------------------------- ctkSettings::ctkSettings(const QString& organization, const QString& application, @@ -134,8 +138,12 @@ void ctkSettings::restoreState(const QString& key, QMainWindow& window) QPoint windowTopLeft = this->value("Position").toPoint(); QRect mwRect(windowTopLeft, window.size()); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QDesktopWidget desktop; QRect desktopRect = desktop.availableGeometry( desktop.primaryScreen() ); +#else + QRect desktopRect = QGuiApplication::primaryScreen()->availableGeometry(); +#endif // try moving it to keep size if(!desktopRect.contains(mwRect)) { diff --git a/Libs/Widgets/ctkSettingsDialog.cpp b/Libs/Widgets/ctkSettingsDialog.cpp index ea0a767e3d..3d74f68ce6 100644 --- a/Libs/Widgets/ctkSettingsDialog.cpp +++ b/Libs/Widgets/ctkSettingsDialog.cpp @@ -25,6 +25,9 @@ #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#define QRegExp QRegularExpression +#endif // CTK includes #include "ctkSettingsPanel.h" #include "ctkSettingsDialog.h" diff --git a/Libs/Widgets/ctkSettingsDialog.h b/Libs/Widgets/ctkSettingsDialog.h index 2bad72f315..7edbfadd6d 100644 --- a/Libs/Widgets/ctkSettingsDialog.h +++ b/Libs/Widgets/ctkSettingsDialog.h @@ -26,12 +26,18 @@ // CTK includes #include "ctkWidgetsExport.h" - +#if CTK_COMPILING_FROM_MOC_CPP +#include +#include +#include +#include "ctkSettingsPanel.h" +#else class QAbstractButton; class QSettings; class QTreeWidgetItem; -class ctkSettingsDialogPrivate; class ctkSettingsPanel; +#endif +class ctkSettingsDialogPrivate; /// \ingroup Widgets class CTK_WIDGETS_EXPORT ctkSettingsDialog : public QDialog diff --git a/Libs/Widgets/ctkSettingsPanel.h b/Libs/Widgets/ctkSettingsPanel.h index 3916ce5daa..6b6dc60ab3 100644 --- a/Libs/Widgets/ctkSettingsPanel.h +++ b/Libs/Widgets/ctkSettingsPanel.h @@ -27,8 +27,11 @@ // CTK includes #include "ctkWidgetsExport.h" - +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +#include +#else class QSettings; +#endif class ctkSettingsPanelPrivate; /// \ingroup Widgets diff --git a/Libs/Widgets/ctkSizeGrip.cpp b/Libs/Widgets/ctkSizeGrip.cpp index 886d53ba0e..f80470e0d3 100644 --- a/Libs/Widgets/ctkSizeGrip.cpp +++ b/Libs/Widgets/ctkSizeGrip.cpp @@ -223,9 +223,14 @@ QSize ctkSizeGrip::sizeHint() const break; }; QStyleOption opt(0); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) opt.init(this); - return (this->style()->sizeFromContents(contents, &opt, minSize, this). - expandedTo(QApplication::globalStrut())); + return this->style()->sizeFromContents(contents, &opt, minSize, this).expandedTo(QApplication::globalStrut()); +#else + opt.initFrom(this); + return this->style()->sizeFromContents(contents, &opt, minSize, this); +#endif + } //------------------------------------------------------------------------------ @@ -262,7 +267,11 @@ void ctkSizeGrip::paintEvent(QPaintEvent *event) default: { QStyleOptionSizeGrip opt; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) opt.init(this); +#else + opt.initFrom(this); +#endif opt.corner = this->isLeftToRight() ? Qt::BottomRightCorner : Qt::BottomLeftCorner; style()->drawControl(QStyle::CE_SizeGrip, &opt, &painter, this); break; @@ -356,9 +365,9 @@ void ctkSizeGrip::mouseMoveEvent(QMouseEvent * e) widgetSizeHint.rheight() = d->WidgetToResize->heightForWidth(widgetSizeHint.width()); } } - +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) widgetSizeHint = widgetSizeHint.expandedTo(QApplication::globalStrut()); - +#endif this->setWidgetSizeHint( QSize(d->Orientations & Qt::Horizontal ? widgetSizeHint.width() : -1, d->Orientations & Qt::Vertical ? widgetSizeHint.height() : -1)); diff --git a/Libs/Widgets/ctkThumbnailLabel.cpp b/Libs/Widgets/ctkThumbnailLabel.cpp index 71879d211a..1106efbc45 100644 --- a/Libs/Widgets/ctkThumbnailLabel.cpp +++ b/Libs/Widgets/ctkThumbnailLabel.cpp @@ -292,7 +292,11 @@ QSize ctkThumbnailLabel::sizeHint()const Q_D(const ctkThumbnailLabel); return d->OriginalThumbnail.isNull() ? this->Superclass::sizeHint() : +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) d->OriginalThumbnail.size().expandedTo(QApplication::globalStrut()); +#else + d->OriginalThumbnail.size(); +#endif } //---------------------------------------------------------------------------- diff --git a/Libs/Widgets/ctkTransferFunctionView.cpp b/Libs/Widgets/ctkTransferFunctionView.cpp index 695a879d06..4ec0b8585c 100644 --- a/Libs/Widgets/ctkTransferFunctionView.cpp +++ b/Libs/Widgets/ctkTransferFunctionView.cpp @@ -90,12 +90,21 @@ void ctkTransferFunctionView::resizeEvent(QResizeEvent * event) } } */ +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QMatrix zoomMatrix; zoomMatrix.scale(event->size().width(), event->size().height()); bool blocked = this->blockSignals(true); this->setMatrix(zoomMatrix); this->blockSignals(blocked); +#else + QTransform zoomMatrix; + zoomMatrix.scale(event->size().width(), event->size().height()); + bool blocked = this->blockSignals(true); + this->setTransform(zoomMatrix); + this->blockSignals(blocked); +#endif this->QGraphicsView::resizeEvent(event); + // Control points are resized by the view transform, we want // fixed size control points, lines... //this->fitInView(this->scene()->sceneRect()); diff --git a/Libs/Widgets/ctkTreeComboBox.cpp b/Libs/Widgets/ctkTreeComboBox.cpp index c5ece5c6d5..5448a7f67c 100644 --- a/Libs/Widgets/ctkTreeComboBox.cpp +++ b/Libs/Widgets/ctkTreeComboBox.cpp @@ -20,12 +20,18 @@ // Qt includes #include +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) #include +#else +#include +#include +#endif #include #include #include #include #include + #if QT_VERSION < QT_VERSION_CHECK(5,0,0) # include #endif @@ -239,8 +245,12 @@ void ctkTreeComboBox::resizePopup() this->initStyleOption(&opt); QRect listRect(style->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxListBoxPopup, this)); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QRect screen = QApplication::desktop()->availableGeometry( QApplication::desktop()->screenNumber(this)); +#else + QRect screen = this->windowHandle()->screen()->availableGeometry(); +#endif QPoint below = this->mapToGlobal(listRect.bottomLeft()); int belowHeight = screen.bottom() - below.y(); QPoint above = this->mapToGlobal(listRect.topLeft()); @@ -291,11 +301,19 @@ void ctkTreeComboBox::resizePopup() // add the frame of the container int marginTop, marginBottom; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) container->getContentsMargins(0, &marginTop, 0, &marginBottom); +#else + container->layout()->getContentsMargins(0, &marginTop, 0, &marginBottom); +#endif heightMargin += marginTop + marginBottom; //add the frame of the view +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) this->view()->getContentsMargins(0, &marginTop, 0, &marginBottom); +#else + this->view()->layout()->getContentsMargins(0, &marginTop, 0, &marginBottom); +#endif //marginTop += static_cast(QObjectPrivate::get(this->view()))->top; //marginBottom += static_cast(QObjectPrivate::get(this->view()))->bottom; heightMargin += marginTop + marginBottom; diff --git a/Libs/Widgets/ctkWidgetsUtils.cpp b/Libs/Widgets/ctkWidgetsUtils.cpp index 911a398a0c..d92c1d55d5 100644 --- a/Libs/Widgets/ctkWidgetsUtils.cpp +++ b/Libs/Widgets/ctkWidgetsUtils.cpp @@ -21,10 +21,15 @@ // Qt includes #include #include +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) #include +#else +#include +#define QGLWidget QOpenGLWidget +#define grabFrameBuffer grabFramebuffer +#endif #include #include - // ctkWidgets includes #include "ctkWidgetsUtils.h" diff --git a/Libs/Widgets/ctkWorkflowButtonBoxWidget.cpp b/Libs/Widgets/ctkWorkflowButtonBoxWidget.cpp index df5304a0d2..f3c99e9511 100644 --- a/Libs/Widgets/ctkWorkflowButtonBoxWidget.cpp +++ b/Libs/Widgets/ctkWorkflowButtonBoxWidget.cpp @@ -194,10 +194,17 @@ void ctkWorkflowButtonBoxWidgetPrivate::updateGoToButtons(ctkWorkflowStep* curre Q_ASSERT(q->layout()); // Change the buttons only if the set of steps to have goTo buttons is either empty or has changed +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QSet goToStepsToHaveButtons = QSet::fromList(this->Workflow->finishSteps()); QSet goToStepsThatHaveButtons = QSet::fromList(this->GoToButtonToStepMap.values()); +#else + QList steps = this->Workflow->finishSteps(); + QSet goToStepsToHaveButtons(steps.begin(), steps.end()); + steps = this->GoToButtonToStepMap.values(); + QSet goToStepsThatHaveButtons(steps.begin(), steps.end()); +#endif // Remove the buttons if the set of steps to have goTo buttons has changed if (goToStepsThatHaveButtons != goToStepsToHaveButtons) diff --git a/Libs/Widgets/ctkWorkflowWidget.cpp b/Libs/Widgets/ctkWorkflowWidget.cpp index 0048fe85e3..c7f2292793 100644 --- a/Libs/Widgets/ctkWorkflowWidget.cpp +++ b/Libs/Widgets/ctkWorkflowWidget.cpp @@ -33,6 +33,10 @@ #include "ctkWorkflowButtonBoxWidget.h" #include "ctkWorkflowGroupBox.h" +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +#include +#endif + // STD includes #include diff --git a/Libs/XNAT/Core/Testing/CMakeLists.txt b/Libs/XNAT/Core/Testing/CMakeLists.txt index 9f7c7d6521..a93fb87a09 100644 --- a/Libs/XNAT/Core/Testing/CMakeLists.txt +++ b/Libs/XNAT/Core/Testing/CMakeLists.txt @@ -22,7 +22,7 @@ ctk_add_executable_utf8(${KIT}CppTests ${Tests} ${KITTests_SRCS} ${KITTests_MOC_ target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES}) if(CTK_QT_VERSION VERSION_GREATER "4") - target_link_libraries(${KIT}CppTests Qt5::Test) + target_link_libraries(${KIT}CppTests Qt${CTK_QT_VERSION}::Test) endif() SIMPLE_TEST(ctkXnatSessionTest) diff --git a/Libs/XNAT/Widgets/CMakeLists.txt b/Libs/XNAT/Widgets/CMakeLists.txt index 505f1d9958..878b6256d6 100644 --- a/Libs/XNAT/Widgets/CMakeLists.txt +++ b/Libs/XNAT/Widgets/CMakeLists.txt @@ -32,7 +32,7 @@ set(KIT_target_libraries) ctkFunctionGetTargetLibraries(KIT_target_libraries) if(CTK_QT_VERSION VERSION_GREATER "4") - list(APPEND KIT_target_libraries Qt5::Widgets) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::Widgets) endif() ctkMacroBuildLib( diff --git a/Plugins/org.commontk.dah.core/CMakeLists.txt b/Plugins/org.commontk.dah.core/CMakeLists.txt index b2577ea4d0..cb9f3dffce 100644 --- a/Plugins/org.commontk.dah.core/CMakeLists.txt +++ b/Plugins/org.commontk.dah.core/CMakeLists.txt @@ -48,7 +48,7 @@ set(PLUGIN_resources ctkFunctionGetTargetLibraries(PLUGIN_target_libraries) if(CTK_QT_VERSION VERSION_GREATER "4") - list(APPEND PLUGIN_target_libraries Qt5::Network Qt5::Widgets) + list(APPEND KIT_target_libraries Qt${CTK_QT_VERSION}::Network Qt${CTK_QT_VERSION}::Widgets) endif() ctkMacroBuildPlugin(