소스 검색

Merge remote-tracking branch 'j2/add-qt5-support' into qt5

Conflicts:
	CMake/CTKConfig.cmake.in
	CMake/ctkMacroBuildLib.cmake
	CMake/ctkMacroBuildPlugin.cmake
	CMake/ctkMacroBuildQtPlugin.cmake
	CMake/ctkMacroGenerateMocs.cmake
	CMake/ctkMacroSetupQt.cmake
	CMake/ctkMacroWrapPythonQt.cmake
	CMake/ctkScriptWrapPythonQt_Light.cmake
	CMakeExternals/PythonQt.cmake
	CMakeExternals/VTK.cmake
	Libs/Core/Testing/Cpp/CMakeLists.txt
	Libs/Core/Testing/Cpp/ctkAbstractLibraryFactoryTest1.cpp
	Libs/Core/ctkAbstractLibraryFactory.h
	Libs/Core/ctkAbstractLibraryFactory.tpp
	Libs/Core/ctkCheckableModelHelper.cpp
	Libs/Core/ctkErrorLogQtMessageHandler.cpp
	Libs/Core/ctkErrorLogQtMessageHandler.h
	Libs/Testing/ctkTest.h
	Libs/Widgets/Testing/Cpp/CMakeLists.txt
	Libs/Widgets/ctkCoordinatesWidget.h
	Libs/Widgets/ctkMaterialPropertyPreviewLabel.cpp
	Libs/Widgets/ctkPopupWidget.cpp
	SuperBuild.cmake
Sascha Zelzer 11 년 전
부모
커밋
77a4db546b
100개의 변경된 파일624개의 추가작업 그리고 273개의 파일을 삭제
  1. 3 0
      CMake/CTKConfig.cmake.in
  2. 1 1
      CMake/ctkFunctionCompileSnippets.cmake
  3. 5 1
      CMake/ctkFunctionGeneratePluginManifest.cmake
  4. 26 11
      CMake/ctkMacroBuildApp.cmake
  5. 4 4
      CMake/ctkMacroBuildLib.cmake
  6. 5 1
      CMake/ctkMacroBuildLibWrapper.cmake
  7. 24 11
      CMake/ctkMacroBuildPlugin.cmake
  8. 5 4
      CMake/ctkMacroBuildQtPlugin.cmake
  9. 2 2
      CMake/ctkMacroGenerateMocs.cmake
  10. 5 1
      CMake/ctkMacroGeneratePluginResourceFile.cmake
  11. 8 8
      CMake/ctkMacroSetupPlugins.cmake
  12. 11 2
      CMake/ctkMacroSetupQt.cmake
  13. 5 1
      CMake/ctkMacroWrapPythonQt.cmake
  14. 12 1
      CMakeExternals/PythonQt.cmake
  15. 11 4
      Libs/CommandLineModules/Core/CMakeLists.txt
  16. 21 10
      Libs/CommandLineModules/Core/Testing/Cpp/CMakeLists.txt
  17. 1 1
      Libs/CommandLineModules/Core/ctkCmdLineModuleXmlProgressWatcher.cpp
  18. 21 9
      Libs/CommandLineModules/Frontend/QtGui/Testing/Cpp/CMakeLists.txt
  19. 19 10
      Libs/CommandLineModules/Testing/Cpp/CMakeLists.txt
  20. 2 1
      Libs/Core/CMakeLists.txt
  21. 2 2
      Libs/Core/Testing/Cpp/CMakeLists.txt
  22. 1 1
      Libs/Core/Testing/Cpp/ctkAbstractLibraryFactoryTest1.cpp
  23. 1 1
      Libs/Core/Testing/Cpp/ctkDummyPlugin.h
  24. 7 7
      Libs/Core/ctkAbstractLibraryFactory.h
  25. 2 2
      Libs/Core/ctkAbstractLibraryFactory.tpp
  26. 2 2
      Libs/Core/ctkErrorLogQtMessageHandler.h
  27. 6 1
      Libs/Core/target_libraries.cmake
  28. 1 1
      Libs/DICOM/Core/ctkDICOMDatabase.cpp
  29. 5 5
      Libs/DICOM/Core/ctkDICOMItem.cpp
  30. 5 5
      Libs/DICOM/Core/ctkDICOMQuery.cpp
  31. 3 0
      Libs/DICOM/Core/target_libraries.cmake
  32. 2 0
      Libs/DICOM/Widgets/Plugins/ctkDICOMWidgetsPlugins.cpp
  33. 3 0
      Libs/DICOM/Widgets/Plugins/ctkDICOMWidgetsPlugins.h
  34. 5 0
      Libs/DICOM/Widgets/ctkDICOMServerNodeWidget.cpp
  35. 7 2
      Libs/PluginFramework/Documentation/Snippets/EventAdmin-Intro/files.cmake
  36. 4 4
      Libs/PluginFramework/Testing/org.commontk.pluginfwtest/ctkPluginFrameworkTestSuite.cpp
  37. 1 1
      Libs/PluginFramework/Testing/org.commontk.pluginfwtest/ctkServiceTrackerTestSuite.cpp
  38. 1 1
      Libs/PluginFramework/ctkPluginFrameworkUtil.cpp
  39. 1 1
      Libs/PluginFramework/ctkServices.cpp
  40. 4 2
      Libs/Scripting/Python/Core/CMakeLists.txt
  41. 10 2
      Libs/Scripting/Python/Core/Python/CMakeLists.txt
  42. 2 13
      Libs/Scripting/Python/Core/Python/qt/__init__.py
  43. 9 3
      Libs/Scripting/Python/Core/Testing/Cpp/CMakeLists.txt
  44. 2 2
      Libs/Scripting/Python/Core/ctkAbstractPythonManager.cpp
  45. 3 0
      Libs/Scripting/Python/Core/ctkScriptingPythonCoreConfigure.h.in
  46. 4 0
      Libs/Scripting/Python/Core/ctk_library_options.cmake
  47. 2 0
      Libs/Scripting/Python/Widgets/Plugins/ctkScriptingPythonWidgetsPlugins.cpp
  48. 6 2
      Libs/Scripting/Python/Widgets/Plugins/ctkScriptingPythonWidgetsPlugins.h
  49. 6 4
      Libs/Scripting/Python/Widgets/ctkPythonConsole.cpp
  50. 5 1
      Libs/Visualization/VTK/Core/Testing/Cpp/CMakeLists.txt
  51. 2 0
      Libs/Visualization/VTK/Widgets/Plugins/ctkVTKWidgetsPlugins.cpp
  52. 6 3
      Libs/Visualization/VTK/Widgets/Plugins/ctkVTKWidgetsPlugins.h
  53. 23 11
      Libs/Visualization/VTK/Widgets/Testing/Cpp/CMakeLists.txt
  54. 5 1
      Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.cpp
  55. 2 2
      Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView_p.h
  56. 4 1
      Libs/Visualization/VTK/Widgets/target_libraries.cmake
  57. 10 2
      Libs/Widgets/CMakeLists.txt
  58. 2 0
      Libs/Widgets/Plugins/ctkWidgetsPlugins.cpp
  59. 7 4
      Libs/Widgets/Plugins/ctkWidgetsPlugins.h
  60. 18 7
      Libs/Widgets/Testing/Cpp/CMakeLists.txt
  61. 7 2
      Libs/Widgets/Testing/Cpp/ctkCheckableComboBoxTest1.cpp
  62. 31 13
      Libs/Widgets/Testing/Cpp/ctkCheckableHeaderViewTest1.cpp
  63. 11 2
      Libs/Widgets/Testing/Cpp/ctkCheckableHeaderViewTest2.cpp
  64. 4 0
      Libs/Widgets/Testing/Cpp/ctkColorDialogTest1.cpp
  65. 4 0
      Libs/Widgets/Testing/Cpp/ctkDoubleRangeSliderTest.cpp
  66. 4 0
      Libs/Widgets/Testing/Cpp/ctkDoubleSliderTest.cpp
  67. 4 0
      Libs/Widgets/Testing/Cpp/ctkDoubleSpinBoxTest.cpp
  68. 5 0
      Libs/Widgets/Testing/Cpp/ctkExpandableWidgetTest1.cpp
  69. 9 0
      Libs/Widgets/Testing/Cpp/ctkMatrixWidgetTest.cpp
  70. 4 0
      Libs/Widgets/Testing/Cpp/ctkPathListWidgetWithButtonsTest.cpp
  71. 0 1
      Libs/Widgets/Testing/Cpp/ctkProxyStyleTest1.cpp
  72. 10 3
      Libs/Widgets/Testing/Cpp/ctkPushButtonTest.cpp
  73. 9 1
      Libs/Widgets/Testing/Cpp/ctkRangeSliderTest.cpp
  74. 4 0
      Libs/Widgets/Testing/Cpp/ctkRangeWidgetTest.cpp
  75. 4 0
      Libs/Widgets/Testing/Cpp/ctkSearchBoxTest.cpp
  76. 12 0
      Libs/Widgets/Testing/Cpp/ctkSliderWidgetTest.cpp
  77. 12 13
      Libs/Widgets/ctkBasePopupWidget.cpp
  78. 3 2
      Libs/Widgets/ctkBasePopupWidget_p.h
  79. 1 2
      Libs/Widgets/ctkButtonGroup.cpp
  80. 0 1
      Libs/Widgets/ctkCheckableComboBox.cpp
  81. 2 2
      Libs/Widgets/ctkCheckableHeaderView.cpp
  82. 0 1
      Libs/Widgets/ctkCheckablePushButton.cpp
  83. 5 1
      Libs/Widgets/ctkCollapsibleButton.cpp
  84. 1 0
      Libs/Widgets/ctkConsole.cpp
  85. 2 2
      Libs/Widgets/ctkCoordinatesWidget_p.h
  86. 2 2
      Libs/Widgets/ctkDoubleRangeSlider.cpp
  87. 2 1
      Libs/Widgets/ctkDoubleSlider.cpp
  88. 2 2
      Libs/Widgets/ctkDoubleSpinBox_p.h
  89. 9 1
      Libs/Widgets/ctkIconEnginePlugin.cpp
  90. 10 8
      Libs/Widgets/ctkIconEnginePlugin.h
  91. 15 15
      Libs/Widgets/ctkMaterialPropertyPreviewLabel.cpp
  92. 0 1
      Libs/Widgets/ctkMenuButton.cpp
  93. 1 0
      Libs/Widgets/ctkMenuComboBox.cpp
  94. 3 3
      Libs/Widgets/ctkMenuComboBox_p.h
  95. 22 3
      Libs/Widgets/ctkPixmapIconEngine.cpp
  96. 11 1
      Libs/Widgets/ctkPixmapIconEngine.h
  97. 13 8
      Libs/Widgets/ctkPopupWidget.cpp
  98. 2 2
      Libs/Widgets/ctkRangeWidget.cpp
  99. 2 1
      Libs/Widgets/ctkScreenshotDialog_p.h
  100. 0 0
      Libs/Widgets/ctkSliderWidget.cpp

+ 3 - 0
CMake/CTKConfig.cmake.in

@@ -76,6 +76,9 @@ include(${CTK_PLUGIN_USE_FILE})
 # CTK external projects variables
 @CTK_SUPERBUILD_EP_VARS_CONFIG@
 
+# Qt configuration
+set(CTK_QT_VERSION "@CTK_QT_VERSION@")
+
 # Update CMake module path so that calling "find_package(DCMTK)" works as expected 
 # after calling "find_package(CTK)"
 # Ideally projects like DCMTK or PythonQt should provide both "Config" and "Use" files.

+ 1 - 1
CMake/ctkFunctionCompileSnippets.cmake

@@ -50,7 +50,7 @@ function(ctkFunctionCompileSnippets snippet_path)
     list(GET main_cpp_dir_tokens -1 snippet_exec_name)
     set(snippet_target_name "Snippet-${snippet_exec_name}")
     add_executable(${snippet_target_name} ${snippet_src_files})
-    if(CTK_USE_QT5 AND qt5_use_modules_list)
+    if(CTK_QT_VERSION VERSION_GREATER "4" AND qt5_use_modules_list)
       qt5_use_modules(${snippet_target_name} ${qt5_use_modules_list})
     endif()
     if(ARGN)

+ 5 - 1
CMake/ctkFunctionGeneratePluginManifest.cmake

@@ -96,7 +96,11 @@ function(ctkFunctionGeneratePluginManifest QRC_SRCS)
   configure_file("${CTK_CMAKE_DIR}/MANIFEST.MF.in" "${_manifest_filepath}" @ONLY)
   configure_file("${CTK_CMAKE_DIR}/plugin_manifest.qrc.in" "${_manifest_qrc_filepath}" @ONLY)
 
-  QT4_ADD_RESOURCES(_qrc_src ${_manifest_qrc_filepath})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    QT5_ADD_RESOURCES(_qrc_src ${_manifest_qrc_filepath})
+  else()
+    QT4_ADD_RESOURCES(_qrc_src ${_manifest_qrc_filepath})
+  endif()
 
   set(${QRC_SRCS} ${${QRC_SRCS}} ${_qrc_src} PARENT_SCOPE)
 

+ 26 - 11
CMake/ctkMacroBuildApp.cmake

@@ -74,17 +74,32 @@ macro(ctkMacroBuildApp)
   set(MY_MOC_CPP)
   set(MY_QRC_SRCS)
 
-  # Wrap
-  if(MY_MOC_SRCS)
-    # this is a workaround for Visual Studio. The relative include paths in the generated
-    # moc files can get very long and can't be resolved by the MSVC compiler.
-    foreach(moc_src ${MY_MOC_SRCS})
-      QT4_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
-    endforeach()
-  endif()
-  QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
-  if(DEFINED MY_RESOURCES)
-    QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    # Wrap
+    if(MY_MOC_SRCS)
+      # this is a workaround for Visual Studio. The relative include paths in the generated
+      # moc files can get very long and can't be resolved by the MSVC compiler.
+      foreach(moc_src ${MY_MOC_SRCS})
+        QT5_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
+      endforeach()
+    endif()
+    QT5_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
+    if(DEFINED MY_RESOURCES)
+      QT5_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
+  else()
+    # Wrap
+    if(MY_MOC_SRCS)
+      # this is a workaround for Visual Studio. The relative include paths in the generated
+      # moc files can get very long and can't be resolved by the MSVC compiler.
+      foreach(moc_src ${MY_MOC_SRCS})
+        QT4_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
+      endforeach()
+    endif()
+    QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
+    if(DEFINED MY_RESOURCES)
+      QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
   endif()
 
   source_group("Resources" FILES

+ 4 - 4
CMake/ctkMacroBuildLib.cmake

@@ -50,8 +50,8 @@ macro(ctkMacroBuildLib)
   
   if(MY_QT5_MODULES)
     set(qt5_use_modules_list)
-    if(NOT CTK_USE_QT5)
-      message(WARNING "Argument QT5_MODULES ignored because CTK_USE_QT5 is not set.")
+    if(CTK_QT_VERSION VERSION_LESS "5")
+      message(WARNING "Argument QT5_MODULES ignored because Qt version < 5.")
     else()
       foreach(qt5_module ${MY_QT5_MODULES})
         find_package(${qt5_module} REQUIRED)
@@ -132,7 +132,7 @@ macro(ctkMacroBuildLib)
   if(MY_GENERATE_MOC_SRCS)
     QT4_GENERATE_MOCS(${MY_GENERATE_MOC_SRCS})
   endif()
-  if(CTK_USE_QT5)
+  if(CTK_QT_VERSION VERSION_GREATER "4")
     if(Qt5Widgets_FOUND)
       qt5_wrap_ui(MY_UI_CPP ${MY_UI_FORMS})
     elseif(MY_UI_FORMS)
@@ -170,7 +170,7 @@ macro(ctkMacroBuildLib)
     ${MY_QRC_SRCS}
     )
     
-  if(CTK_USE_QT5 AND qt5_use_modules_list)
+  if(CTK_QT_VERSION VERSION_GREATER "4" AND qt5_use_modules_list)
     qt5_use_modules(${lib_name} ${qt5_use_modules_list})
   endif()
 

+ 5 - 1
CMake/ctkMacroBuildLibWrapper.cmake

@@ -93,7 +93,11 @@ macro(ctkMacroBuildLibWrapper)
     KIT_PYTHONQT_SRCS "${MY_SRCS}" FALSE ${HAS_DECORATOR})
   if(HAS_DECORATOR)
     list(APPEND KIT_PYTHONQT_SRCS ${DECORATOR_HEADER})
-    QT4_WRAP_CPP(KIT_PYTHONQT_SRCS ${DECORATOR_HEADER} OPTIONS -f${DECORATOR_HEADER})
+    if (CTK_QT_VERSION VERSION_GREATER "4")
+      qt5_wrap_cpp(KIT_PYTHONQT_SRCS ${DECORATOR_HEADER} OPTIONS -f${DECORATOR_HEADER})
+    else()
+      QT4_WRAP_CPP(KIT_PYTHONQT_SRCS ${DECORATOR_HEADER} OPTIONS -f${DECORATOR_HEADER})
+    endif()
   endif()
   add_library(${lib_name}PythonQt ${MY_WRAPPER_LIBRARY_TYPE} ${KIT_PYTHONQT_SRCS})
   target_link_libraries(${lib_name}PythonQt ${lib_name} ${my_EXTRA_PYTHON_LIBRARIES})

+ 24 - 11
CMake/ctkMacroBuildPlugin.cmake

@@ -170,18 +170,31 @@ macro(ctkMacroBuildPlugin)
   set(MY_QRC_SRCS)
 
   # Wrap
-  if(MY_MOC_SRCS)
-    # this is a workaround for Visual Studio. The relative include paths in the generated
-    # moc files can get very long and can't be resolved by the MSVC compiler.
-    foreach(moc_src ${MY_MOC_SRCS})
-      QT4_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src} ${MY_MOC_OPTIONS})
-    endforeach()
-  endif()
-  QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
-  if(DEFINED MY_RESOURCES)
-    QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    if(MY_MOC_SRCS)
+      # this is a workaround for Visual Studio. The relative include paths in the generated
+      # moc files can get very long and can't be resolved by the MSVC compiler.
+      foreach(moc_src ${MY_MOC_SRCS})
+        QT5_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
+      endforeach()
+    endif()
+    QT5_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
+    if(DEFINED MY_RESOURCES)
+      QT5_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
+  else()
+    if(MY_MOC_SRCS)
+      # this is a workaround for Visual Studio. The relative include paths in the generated
+      # moc files can get very long and can't be resolved by the MSVC compiler.
+      foreach(moc_src ${MY_MOC_SRCS})
+        QT4_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
+      endforeach()
+    endif()
+    QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
+    if(DEFINED MY_RESOURCES)
+      QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
   endif()
-
   # Add the generated manifest qrc file
   set(manifest_qrc_src )
   ctkFunctionGeneratePluginManifest(manifest_qrc_src

+ 5 - 4
CMake/ctkMacroBuildQtPlugin.cmake

@@ -46,8 +46,8 @@ macro(ctkMacroBuildQtPlugin)
   
   if(MY_QT5_MODULES)
     set(qt5_use_modules_list)
-    if(NOT CTK_USE_QT5)
-      message(WARNING "Argument QT5_MODULES ignored because CTK_USE_QT5 is not set.")
+    if(CTK_QT_VERSION VERSION_LOWER "5")
+      message(WARNING "Argument QT5_MODULES ignored because Qt version < 5")
     else()
       foreach(qt5_module ${MY_QT5_MODULES})
         find_package(${qt5_module} REQUIRED)
@@ -63,6 +63,7 @@ macro(ctkMacroBuildQtPlugin)
 
   # --------------------------------------------------------------------------
   # Include dirs
+
   set(my_includes
     ${CTK_BASE_INCLUDE_DIRS}
     ${QT_QTDESIGNER_INCLUDE_DIR}
@@ -109,7 +110,7 @@ macro(ctkMacroBuildQtPlugin)
     endif()
   endif()
   
-  if(CTK_USE_QT5)
+  if(CTK_QT_VERSION VERSION_GREATER "4")
     if(Qt5Widgets_FOUND)
       qt5_wrap_ui(MY_UI_CPP ${MY_UI_FORMS})
     elseif(MY_UI_FORMS)
@@ -137,7 +138,7 @@ macro(ctkMacroBuildQtPlugin)
     ${MY_QRC_SRCS}
     )
   
-  if(CTK_USE_QT5 AND qt5_use_modules_list)
+  if(CTK_QT_VERSION VERSION_GREATER "4" AND qt5_use_modules_list)
     qt5_use_modules(${lib_name} ${qt5_use_modules_list})
   endif()
 

+ 2 - 2
CMake/ctkMacroGenerateMocs.cmake

@@ -4,7 +4,7 @@
 include(MacroAddFileDependencies)
 
 function(QT4_GENERATE_MOCS)
-  if(CTK_USE_QT5)
+  if(CTK_QT_VERSION VERSION_GREATER "4")
     QT5_GET_MOC_FLAGS(_moc_flags)
   else()
     QT4_GET_MOC_FLAGS(_moc_flags)
@@ -25,7 +25,7 @@ function(QT4_GENERATE_MOCS)
 
     set(moc_file ${CMAKE_CURRENT_BINARY_DIR}/moc_${source_name}${source_ext})
 
-    if(CTK_USE_QT5)
+    if(CTK_QT_VERSION VERSION_GREATER "4")
       QT5_CREATE_MOC_COMMAND(${abs_file} ${moc_file} "${_moc_flags}" "" "")
     else()
       QT4_CREATE_MOC_COMMAND(${abs_file} ${moc_file} "${_moc_flags}" "" "")

+ 5 - 1
CMake/ctkMacroGeneratePluginResourceFile.cmake

@@ -39,6 +39,10 @@ macro(ctkMacroGeneratePluginResourceFile QRC_SRCS)
 ")
   configure_file("${CTK_CMAKE_DIR}/plugin_resources_cached.qrc.in" "${_qrc_filepath}" @ONLY)
 
-  QT4_ADD_RESOURCES(${QRC_SRCS} ${_qrc_filepath})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    QT5_ADD_RESOURCES(${QRC_SRCS} ${_qrc_filepath})
+  else()
+    QT4_ADD_RESOURCES(${QRC_SRCS} ${_qrc_filepath})
+  endif()
 
 endmacro()

+ 8 - 8
CMake/ctkMacroSetupPlugins.cmake

@@ -102,14 +102,14 @@ macro(ctkMacroSetupPlugins )
   endif()
   
   # Set up Qt, if not already done
-  if(NOT QT4_FOUND)
-    set(minimum_required_qt_version "4.6")
-    find_package(Qt4 REQUIRED)
-
-    if("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_LESS "${minimum_required_qt_version}")
-      message(FATAL_ERROR "error: CTK requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.")
-    endif()
-  endif()
+  #if(NOT QT4_FOUND)
+  #  set(minimum_required_qt_version "4.6")
+  #  find_package(Qt4 REQUIRED)
+
+  #  if("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_LESS "${minimum_required_qt_version}")
+  #    message(FATAL_ERROR "error: CTK requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.")
+  #  endif()
+  #endif()
   
   # Set the variable QT_INSTALLED_LIBRARY_DIR that contains all
   # Qt shared libraries

+ 11 - 2
CMake/ctkMacroSetupQt.cmake

@@ -20,8 +20,17 @@
 
 #! \ingroup CMakeUtilities
 macro(ctkMacroSetupQt)
+  set(CTK_QT_VERSION "4" CACHE STRING "Expected Qt version")
+  mark_as_advanced(CTK_QT_VERSION)
 
-  if(CTK_USE_QT5)
+  set_property(CACHE CTK_QT_VERSION PROPERTY STRINGS 4 5)
+
+  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'")
+  endif()
+
+
+  if(CTK_QT_VERSION VERSION_GREATER "4")
     cmake_minimum_required(VERSION 2.8.9)
     set(QT5_INSTALL_PREFIX "" CACHE PATH "The install location of Qt5")
     if(NOT QT5_INSTALL_PREFIX OR NOT EXISTS ${QT5_INSTALL_PREFIX}/bin/qmake)
@@ -32,7 +41,7 @@ macro(ctkMacroSetupQt)
     set(minimum_required_qt_version "4.6")
 
     find_package(Qt4)
-    
+
     if(QT4_FOUND)
 
       if("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_LESS "${minimum_required_qt_version}")

+ 5 - 1
CMake/ctkMacroWrapPythonQt.cmake

@@ -164,7 +164,11 @@ macro(ctkMacroWrapPythonQt WRAPPING_NAMESPACE TARGET SRCS_LIST_NAME SOURCES IS_W
     VERBATIM
     )
 
-  QT4_WRAP_CPP(${TARGET}_MOC_CXX ${CMAKE_CURRENT_BINARY_DIR}/${wrapper_h_filename})
+  if (CTK_QT_VERSION VERSION_EQUAL "4")
+    QT5_WRAP_CPP(${TARGET}_MOC_CXX ${CMAKE_CURRENT_BINARY_DIR}/${wrapper_h_filename})
+  else()
+    QT4_WRAP_CPP(${TARGET}_MOC_CXX ${CMAKE_CURRENT_BINARY_DIR}/${wrapper_h_filename})
+  endif()
 
   # The following files are generated
   set_source_files_properties(

+ 12 - 1
CMakeExternals/PythonQt.cmake

@@ -32,7 +32,18 @@ if(NOT DEFINED PYTHONQT_INSTALL_DIR)
   endif()
 
   # Enable Qt libraries PythonQt wrapping if required
-  set(qtlibs core gui network opengl sql svg uitools webkit xml)
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    list(APPEND ep_PythonQt_args
+      -DPythonQt_QT_VERSION:STRING=${CTK_QT_VERSION}
+      -DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}
+      )
+    set(qtlibs Core Gui Widgets Network OpenGL PrintSupport Sql Svg UiTools WebKit WebKitWidgets Xml)
+  else()
+    list(APPEND ep_PythonQt_args
+      -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
+      )
+    set(qtlibs core gui network opengl sql svg uitools webkit xml)
+  endif()
   foreach(qtlib All ${qtlibs})
     string(TOUPPER ${qtlib} qtlib_uppercase)
     list(APPEND ep_PythonQt_args -DPythonQt_Wrap_Qt${qtlib}:BOOL=${CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib_uppercase}})

+ 11 - 4
Libs/CommandLineModules/Core/CMakeLists.txt

@@ -59,10 +59,17 @@ set(KIT_MOC_SRCS
   ctkCmdLineModuleManager.h
 )
 
-QT4_GENERATE_MOCS(
-  ctkCmdLineModuleFrontend.h
-  ctkCmdLineModuleXmlProgressWatcher.h
-)
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_GENERATE_MOCS(
+    ctkCmdLineModuleFrontend.h
+    ctkCmdLineModuleXmlProgressWatcher.h
+    )
+else()
+  QT4_GENERATE_MOCS(
+    ctkCmdLineModuleFrontend.h
+    ctkCmdLineModuleXmlProgressWatcher.h
+    )
+endif()
 
 #list(APPEND KIT_SRCS
 #  ${CMAKE_CURRENT_BINARY_DIR}/moc_ctkCmdLineModuleXmlProgressWatcher.h

+ 21 - 10
Libs/CommandLineModules/Core/Testing/Cpp/CMakeLists.txt

@@ -23,18 +23,29 @@ include_directories(
   )
 
 set(Tests_MOC_CPP)
-QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
-QT4_GENERATE_MOCS(
-  ctkCmdLineModuleManagerTest.cpp
-  ctkCmdLineModuleXmlProgressWatcherTest.cpp
-)
 set(Tests_UI_CPP)
-if(TEST_UI_FORMS)
-  QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
-endif()
 set(Tests_RESOURCES_SRCS)
-QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
-
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  QT5_GENERATE_MOCS(
+    ctkCmdLineModuleManagerTest.cpp
+    ctkCmdLineModuleXmlProgressWatcherTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT5_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT5_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+else()
+  QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  QT4_GENERATE_MOCS(
+    ctkCmdLineModuleManagerTest.cpp
+    ctkCmdLineModuleXmlProgressWatcherTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+endif()
 add_executable(${KIT}CppTests ${Tests} ${Tests_SRCS} ${Tests_MOC_CPP} ${Tests_UI_CPP} ${Tests_RESOURCES_SRCS})
 target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES})
 

+ 1 - 1
Libs/CommandLineModules/Core/ctkCmdLineModuleXmlProgressWatcher.cpp

@@ -90,7 +90,7 @@ public:
       {
         if (stack.empty())
         {
-          QByteArray output(reader.text().toString().toAscii());
+          QByteArray output(reader.text().toString().toLatin1());
           // get rid of a possible newline after the last xml end tag
           if (output.startsWith('\n')) output = output.remove(0,1);
           outputData.append(output);

+ 21 - 9
Libs/CommandLineModules/Frontend/QtGui/Testing/Cpp/CMakeLists.txt

@@ -25,17 +25,29 @@ include_directories(
   )
 
 set(Tests_MOC_CPP)
-QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
-QT4_GENERATE_MOCS(
-  ctkCmdLineModuleFrontendQtGuiTest.cpp
-  ctkCmdLineModuleQtXslTransformTest.cpp
-  )
 set(Tests_UI_CPP)
-if(TEST_UI_FORMS)
-  QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
-endif()
 set(Tests_RESOURCES_SRCS)
-QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  QT5_GENERATE_MOCS(
+    ctkCmdLineModuleFrontendQtGuiTest.cpp
+    ctkCmdLineModuleQtXslTransformTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT5_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT5_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+else()
+  QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  QT4_GENERATE_MOCS(
+    ctkCmdLineModuleFrontendQtGuiTest.cpp
+    ctkCmdLineModuleQtXslTransformTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+endif()
 
 add_executable(${KIT}CppTests ${Tests} ${Tests_SRCS} ${Tests_MOC_CPP} ${Tests_UI_CPP} ${Tests_RESOURCES_SRCS})
 target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES})

+ 19 - 10
Libs/CommandLineModules/Testing/Cpp/CMakeLists.txt

@@ -68,18 +68,27 @@ if(CTK_LIB_CommandLineModules/Frontend/QtGui)
 endif()
 
 set(Tests_MOC_CPP)
-QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
-
-if(_test_mocs)
-  QT4_GENERATE_MOCS(${_test_mocs})
-endif()
-
 set(Tests_UI_CPP)
-if(TEST_UI_FORMS)
-  QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
-endif()
 set(Tests_RESOURCES_SRCS)
-QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  if(_test_mocs)
+    QT5_GENERATE_MOCS(${_test_mocs})
+  endif()
+  if(TEST_UI_FORMS)
+    QT5_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT5_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+else()
+  QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  if(_test_mocs)
+    QT4_GENERATE_MOCS(${_test_mocs})
+  endif()
+  if(TEST_UI_FORMS)
+    QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+endif()
 
 add_executable(${KIT}CppTests ${Tests} ${Tests_SRCS} ${Tests_MOC_CPP} ${Tests_UI_CPP} ${Tests_RESOURCES_SRCS})
 target_link_libraries(${KIT}CppTests ${_additional_link_libraries})

+ 2 - 1
Libs/Core/CMakeLists.txt

@@ -99,6 +99,7 @@ set(KIT_MOC_SRCS
   ctkCommandLineParser.h
   ctkErrorLogFDMessageHandler_p.h
   ctkErrorLogModel.h
+  ctkErrorLogQtMessageHandler.h
   ctkLinearValueProxy.h
   ctkLogger.h
   ctkHistogram.h
@@ -127,7 +128,7 @@ set(KIT_target_libraries)
 
 ctkFunctionGetTargetLibraries(KIT_target_libraries)
 
-if(CTK_USE_QT5)
+if(CTK_QT_VERSION VERSION_GREATER "4")
   # This line below should actually be
   # set(qt5_modules Qt5Core)
   # see https://github.com/commontk/CTK/issues/278

+ 2 - 2
Libs/Core/Testing/Cpp/CMakeLists.txt

@@ -107,7 +107,7 @@ set(Tests_Helpers_MOC_CPPS
   )
 
 set(Tests_Helpers_MOC_CPP)
-if(CTK_USE_QT5)
+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})
 else()
@@ -129,7 +129,7 @@ endif()
 add_executable(${KIT}CppTests ${Tests} ${Tests_Helpers_SRCS} ${Tests_Helpers_MOC_CPP})
 target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES} CTKDummyPlugin)
 
-if(CTK_USE_QT5)
+if(CTK_QT_VERSION VERSION_GREATER "4")
   qt5_use_modules(${KIT}CppTests Test Widgets)
 endif()
 

+ 1 - 1
Libs/Core/Testing/Cpp/ctkAbstractLibraryFactoryTest1.cpp

@@ -45,7 +45,7 @@ protected:
     QScopedPointer<ctkDummyLibrary> module(new ctkDummyLibrary());
     foreach(QString symbol, this->Symbols)
       {
-      SymbolAdressType res = this->symbolAddress(symbol);
+      SymbolAddressType res = this->symbolAddress(symbol);
       if (!res)
         {
         }

+ 1 - 1
Libs/Core/Testing/Cpp/ctkDummyPlugin.h

@@ -34,7 +34,7 @@ class CTK_DUMMY_EXPORT ctkDummyPlugin: public QObject//, public ctkDummyInterfac
 {
   Q_OBJECT
 //  Q_INTERFACES(ctkDummyInterface)
-#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+#if QT_VERSION >= 0x50000
   Q_PLUGIN_METADATA(IID "org.commontk.DummyPlugin")
 #endif
 public:

+ 7 - 7
Libs/Core/ctkAbstractLibraryFactory.h

@@ -37,15 +37,15 @@ class ctkFactoryLibraryItem : public ctkAbstractFactoryFileBasedItem<BaseClassTy
 
 public:
 
-#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
-  typedef void* SymbolAdressType;
+#if QT_VERSION < 0x50000
+  typedef void* SymbolAddressType;
 #else
-  typedef QFunctionPointer SymbolAdressType;
+  typedef QFunctionPointer SymbolAddressType;
 #endif
 
 protected:
-  typedef typename QHash<QString, SymbolAdressType>::const_iterator ConstIterator;
-  typedef typename QHash<QString, SymbolAdressType>::iterator       Iterator;
+  typedef typename QHash<QString, SymbolAddressType>::const_iterator ConstIterator;
+  typedef typename QHash<QString, SymbolAddressType>::iterator       Iterator;
 
 public:
   //explicit ctkFactoryLibraryItem(const QString& path);
@@ -64,11 +64,11 @@ public:
   
   /// 
   /// Get symbol address
-  SymbolAdressType symbolAddress(const QString& symbol)const;
+  SymbolAddressType symbolAddress(const QString& symbol)const;
 
 protected:
   mutable QLibrary      Library;
-  QHash<QString, SymbolAdressType> ResolvedSymbols;
+  QHash<QString, SymbolAddressType> ResolvedSymbols;
   QStringList           Symbols;
 };
 

+ 2 - 2
Libs/Core/ctkAbstractLibraryFactory.tpp

@@ -83,7 +83,7 @@ bool ctkFactoryLibraryItem<BaseClassType>::resolve()
       continue;
       }
 
-    SymbolAdressType resolvedSymbol = this->Library.resolve(symbol.toLatin1());
+    SymbolAddressType resolvedSymbol = this->Library.resolve(symbol.toLatin1());
     if (!resolvedSymbol)
       {
       this->appendLoadErrorString(QString("Failed to resolve mandatory symbol '%1'").arg(symbol));
@@ -96,7 +96,7 @@ bool ctkFactoryLibraryItem<BaseClassType>::resolve()
 
 //-----------------------------------------------------------------------------
 template<typename BaseClassType>
-typename ctkFactoryLibraryItem<BaseClassType>::SymbolAdressType
+typename ctkFactoryLibraryItem<BaseClassType>::SymbolAddressType
 ctkFactoryLibraryItem<BaseClassType>::symbolAddress(const QString& symbol)const
 {
   ConstIterator iter = this->ResolvedSymbols.find(symbol);

+ 2 - 2
Libs/Core/ctkErrorLogQtMessageHandler.h

@@ -26,7 +26,7 @@
 #include "ctkCoreExport.h"
 
 // Qt includes
-#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+#if QT_VERSION >= 0x50000
 #include <QtMessageHandler>
 #endif
 
@@ -46,7 +46,7 @@ public:
   virtual QString handlerName()const;
   virtual void setEnabledInternal(bool value);
 
-#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+#if QT_VERSION >= 0x50000
   QtMessageHandler SavedQtMessageHandler;
 #else
   QtMsgHandler SavedQtMessageHandler;

+ 6 - 1
Libs/Core/target_libraries.cmake

@@ -5,6 +5,11 @@
 #
 
 set(target_libraries
-  QT_LIBRARIES
   BFD_LIBRARIES
   )
+
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  list(APPEND target_libraries Qt5Core_LIBRARIES Qt5Widgets_LIBRARIES )
+else()
+  list(APPEND target_libraries QT_LIBRARIES)
+endif()

+ 1 - 1
Libs/DICOM/Core/ctkDICOMDatabase.cpp

@@ -1336,7 +1336,7 @@ void ctkDICOMDatabasePrivate::insert( const ctkDICOMItem& ctkDataset, const QStr
                 && (thumbnailInfo.lastModified() > QFileInfo(filename).lastModified())))
             {
               QDir(q->databaseDirectory() + "/thumbs/").mkpath(studySeriesDirectory);
-              DicomImage dcmImage(QDir::toNativeSeparators(filename).toAscii());
+              DicomImage dcmImage(QDir::toNativeSeparators(filename).toLatin1());
               thumbnailGenerator->generateThumbnail(&dcmImage, thumbnailPath);
             }
         }

+ 5 - 5
Libs/DICOM/Core/ctkDICOMItem.cpp

@@ -115,7 +115,7 @@ void ctkDICOMItem::InitializeFromFile(const QString& filename,
   DcmDataset *dataset;
 
   DcmFileFormat fileformat;
-  OFCondition status = fileformat.loadFile(filename.toAscii().data(), readXfer, groupLength, maxReadLength, readMode);
+  OFCondition status = fileformat.loadFile(filename.toLatin1().data(), readXfer, groupLength, maxReadLength, readMode);
   dataset = fileformat.getAndRemoveDataset();
 
   if (!status.good())
@@ -157,7 +157,7 @@ void ctkDICOMItem::Serialize()
   // construct Qt type from that contents
   QByteArray qtArray = QByteArray::fromRawData( static_cast<const char*>(readbuffer), datasetsize );
   //std::cerr << "** Buffer size: " << qtArray.size() << std::endl;
-  QString stringbuffer = QString::fromAscii(qtArray.toBase64());
+  QString stringbuffer = QString::fromLatin1(qtArray.toBase64());
 
   //std::cerr << "** String of size " << stringbuffer.size() << " looks like this:\n" << stringbuffer.toStdString() << std::endl << std::endl;
 
@@ -207,7 +207,7 @@ void ctkDICOMItem::Deserialize()
 
   //std::cerr << "** " << (void*)this << " ctkDICOMItem: Deserialize Dataset from string of size " << stringbuffer.size() << "\n" << stringbuffer.toStdString() << std::endl;
 
-  QByteArray qtArray = QByteArray::fromBase64( stringbuffer.toAscii() );
+  QByteArray qtArray = QByteArray::fromBase64( stringbuffer.toLatin1() );
   //std::cerr << "** " << (void*)this << " ctkDICOMItem: Deserialize Dataset from byte array of size " << qtArray.size() << std::endl;
 
   DcmInputBufferStream dcmbuffer;
@@ -390,11 +390,11 @@ QString ctkDICOMItem::Decode( const DcmTag& tag, const OFString& raw ) const
       QString encodingName( qtEncodingNamesForDICOMEncodingNames[d->m_SpecificCharacterSet] );
       if ( !decoders.contains( encodingName ) )
       {
-        QTextCodec* codec = QTextCodec::codecForName( encodingName.toAscii() );
+        QTextCodec* codec = QTextCodec::codecForName( encodingName.toLatin1() );
         if (!codec)
         {
           std::cerr << "Could not create QTextCodec object for '" << encodingName.toStdString() << "'. Using default encoding instead." << std::endl;
-          decoders.insert( encodingName, QTextCodec::codecForCStrings()->makeDecoder() ); // uses Latin1
+          decoders.insert( encodingName, QTextCodec::codecForName("UTF-8")->makeDecoder() ); // uses Latin1
         }
         else
         {

+ 5 - 5
Libs/DICOM/Core/ctkDICOMQuery.cpp

@@ -331,19 +331,19 @@ bool ctkDICOMQuery::query(ctkDICOMDatabase& database )
       {
       // make the filter a wildcard in dicom style
       d->Query->putAndInsertString( DCM_PatientName,
-        (QString("*") + d->Filters[key].toString() + QString("*")).toAscii().data());
+        (QString("*") + d->Filters[key].toString() + QString("*")).toLatin1().data());
       }
     else if ( key == QString("Study") && !d->Filters[key].toString().isEmpty())
       {
       // make the filter a wildcard in dicom style
       d->Query->putAndInsertString( DCM_StudyDescription,
-        (QString("*") + d->Filters[key].toString() + QString("*")).toAscii().data());
+        (QString("*") + d->Filters[key].toString() + QString("*")).toLatin1().data());
       }
     else if ( key == QString("ID") && !d->Filters[key].toString().isEmpty())
       {
       // make the filter a wildcard in dicom style
       d->Query->putAndInsertString( DCM_PatientID,
-        (QString("*") + d->Filters[key].toString() + QString("*")).toAscii().data());
+        (QString("*") + d->Filters[key].toString() + QString("*")).toLatin1().data());
       }
     else if ( key == QString("Modalities") && !d->Filters[key].toString().isEmpty())
       {
@@ -355,7 +355,7 @@ bool ctkDICOMQuery::query(ctkDICOMDatabase& database )
       }
       modalitySearch.chop(1); // remove final backslash
       logger.debug("modalityInStudySearch " + modalitySearch);
-      d->Query->putAndInsertString( DCM_ModalitiesInStudy, modalitySearch.toAscii().data() );
+      d->Query->putAndInsertString( DCM_ModalitiesInStudy, modalitySearch.toLatin1().data() );
       }
     // Rememer Series Description for later series query if we go through the keys now
     else if ( key == QString("Series") && !d->Filters[key].toString().isEmpty())
@@ -374,7 +374,7 @@ bool ctkDICOMQuery::query(ctkDICOMDatabase& database )
     QString dateRange = d->Filters["StartDate"].toString() +
                         QString("-") +
                         d->Filters["EndDate"].toString();
-    d->Query->putAndInsertString ( DCM_StudyDate, dateRange.toAscii().data() );
+    d->Query->putAndInsertString ( DCM_StudyDate, dateRange.toLatin1().data() );
     logger.debug("Query on study date " + dateRange);
     }
   emit progress(30);

+ 3 - 0
Libs/DICOM/Core/target_libraries.cmake

@@ -8,3 +8,6 @@ set(target_libraries
   CTKCore
   DCMTK_LIBRARIES
   )
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  list(APPEND target_libraries Qt5Sql_LIBRARIES)
+endif()

+ 2 - 0
Libs/DICOM/Widgets/Plugins/ctkDICOMWidgetsPlugins.cpp

@@ -24,4 +24,6 @@
 // CTK includes
 #include "ctkDICOMWidgetsPlugins.h"
 
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
 Q_EXPORT_PLUGIN2(customwidgetplugin, ctkDICOMWidgetsPlugins);
+#endif

+ 3 - 0
Libs/DICOM/Widgets/Plugins/ctkDICOMWidgetsPlugins.h

@@ -36,6 +36,9 @@ class CTK_DICOM_WIDGETS_PLUGINS_EXPORT ctkDICOMWidgetsPlugins
   , public QDesignerCustomWidgetCollectionInterface
 {
   Q_OBJECT
+#if QT_VERSION >= 0x50000
+  Q_PLUGIN_METADATA(IID "org.commontk.DICOM")
+#endif
   Q_INTERFACES(QDesignerCustomWidgetCollectionInterface);
 
 public:

+ 5 - 0
Libs/DICOM/Widgets/ctkDICOMServerNodeWidget.cpp

@@ -64,8 +64,13 @@ ctkDICOMServerNodeWidget::ctkDICOMServerNodeWidget(QWidget* parentWidget)
     NameColumn, Qt::Horizontal, static_cast<int>(Qt::Unchecked), Qt::CheckStateRole);
   QHeaderView* previousHeaderView = d->NodeTable->horizontalHeader();
   ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(Qt::Horizontal, d->NodeTable);
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  headerView->setSectionsClickable(previousHeaderView->sectionsClickable());
+  headerView->setSectionsMovable(previousHeaderView->sectionsMovable());
+#else
   headerView->setClickable(previousHeaderView->isClickable());
   headerView->setMovable(previousHeaderView->isMovable());
+#endif
   headerView->setHighlightSections(previousHeaderView->highlightSections());
   headerView->checkableModelHelper()->setPropagateDepth(-1);
   d->NodeTable->setHorizontalHeader(headerView);

+ 7 - 2
Libs/PluginFramework/Documentation/Snippets/EventAdmin-Intro/files.cmake

@@ -8,6 +8,11 @@ set(_moc_files
 )
 
 foreach(_moc_file ${_moc_files})
-  QT4_WRAP_CPP(snippet_src_files EventAdmin-Intro/${_moc_file}
-               OPTIONS -f${CMAKE_CURRENT_SOURCE_DIR}/EventAdmin-Intro/${_moc_file})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    QT5_WRAP_CPP(snippet_src_files EventAdmin-Intro/${_moc_file}
+      OPTIONS -f${CMAKE_CURRENT_SOURCE_DIR}/EventAdmin-Intro/${_moc_file})
+  else()
+    QT4_WRAP_CPP(snippet_src_files EventAdmin-Intro/${_moc_file}
+      OPTIONS -f${CMAKE_CURRENT_SOURCE_DIR}/EventAdmin-Intro/${_moc_file})
+  endif()
 endforeach()

+ 4 - 4
Libs/PluginFramework/Testing/org.commontk.pluginfwtest/ctkPluginFrameworkTestSuite.cpp

@@ -63,7 +63,7 @@ void ctkPluginFrameworkTestSuite::initTestCase()
   catch (const ctkException& e)
   {
     QString msg  = QString("plugin framework test suite ") + e.what() + ": SETUP:FAIL";
-    QFAIL(msg.toAscii());
+    QFAIL(msg.toLatin1());
   }
 
   try
@@ -77,7 +77,7 @@ void ctkPluginFrameworkTestSuite::initTestCase()
   catch (const ctkException& e)
   {
     QString msg  = QString("plugin framework test suite ") + e.what() + ": SETUP:FAIL";
-    QFAIL(msg.toAscii());
+    QFAIL(msg.toLatin1());
   }
 
   try
@@ -91,7 +91,7 @@ void ctkPluginFrameworkTestSuite::initTestCase()
   catch (const ctkException& e)
   {
     QString msg  = QString("plugin framework test suite ") + e.what() + ": SETUP:FAIL";
-    QFAIL(msg.toAscii());
+    QFAIL(msg.toLatin1());
   }
 
   try
@@ -101,7 +101,7 @@ void ctkPluginFrameworkTestSuite::initTestCase()
   catch (const ctkException& e)
   {
     QString msg  = QString("plugin framework test suite ") + e.what() + ": SETUP:FAIL";
-    QFAIL(msg.toAscii());
+    QFAIL(msg.toLatin1());
   }
 
   qDebug() << "### plugin framework test suite: SETUP:PASS";

+ 1 - 1
Libs/PluginFramework/Testing/org.commontk.pluginfwtest/ctkServiceTrackerTestSuite.cpp

@@ -64,7 +64,7 @@ void ctkServiceTrackerTestSuite::runTest()
   catch (const ctkPluginException& pexcS)
   {
     QString msg = QString("Test plugin: ") + pexcS.what();
-    QFAIL(msg.toAscii());
+    QFAIL(msg.toLatin1());
   }
 
   // 1. Create a ctkServiceTracker with ctkServiceTrackerCustomizer == null

+ 1 - 1
Libs/PluginFramework/ctkPluginFrameworkUtil.cpp

@@ -64,7 +64,7 @@ public:
       else
       {
         QChar c = s.at(pos);
-        switch (c.toAscii())
+        switch (c.toLatin1())
         {
         case '"':
           quote = !quote;

+ 1 - 1
Libs/PluginFramework/ctkServices.cpp

@@ -151,7 +151,7 @@ void ctkServices::updateServiceRegistrationOrder(const ctkServiceRegistration& s
 //----------------------------------------------------------------------------
 bool ctkServices::checkServiceClass(QObject* service, const QString& cls) const
 {
-  return service->inherits(cls.toAscii());
+  return service->inherits(cls.toLatin1());
 }
 
 //----------------------------------------------------------------------------

+ 4 - 2
Libs/Scripting/Python/Core/CMakeLists.txt

@@ -28,9 +28,11 @@ set(KIT_resources
 #
 # Configure file describing which Qt modules are wrapped
 #
-foreach(qtlib CORE GUI NETWORK OPENGL SQL SVG UITOOLS WEBKIT XML XMLPATTERNS)
+set(QT_PYTHON_WRAPPED_LIBRARIES_LIST Core Gui Widgets Network OpenGL Sql Svg UiTools WebKit WebKitWidgets Xml XmlPatterns)
+foreach(qtlib ${QT_PYTHON_WRAPPED_LIBRARIES_LIST})
+  string(TOUPPER ${qtlib} qtlib)
   set(CTK_PYTHONQT_WRAP_QT${qtlib} ${CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib}})
-  #message(CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib}:${CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib}})
+  message(CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib}:${CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib}})
 endforeach()
 
 configure_file(

+ 10 - 2
Libs/Scripting/Python/Core/Python/CMakeLists.txt

@@ -1,8 +1,16 @@
 
 
-set(KIT_PYTHON_SCRIPTS
-  qt/__init__
+set(KIT_PYTHON_SCRIPTS)
+
+string(REPLACE ";" "', '" QT_PYTHON_WRAPPED_LIBRARIES "${QT_PYTHON_WRAPPED_LIBRARIES_LIST}" )
+set(QT_PYTHON_WRAPPED_LIBRARIES "'${QT_PYTHON_WRAPPED_LIBRARIES}'")
+
+configure_file(
+  qt/__init__.py.in
+  ${CMAKE_CURRENT_BINARY_DIR}/qt/__init__.py
+  @ONLY
   )
+list(APPEND KIT_PYTHON_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/qt/__init__.py)
 
 # If it applies, the variable CTK_PYTHON_WRAPPED_LIBRARIES will contain
 # the comma separated list of package to load

+ 2 - 13
Libs/Scripting/Python/Core/Python/qt/__init__.py

@@ -1,18 +1,7 @@
 """ This module loads all the classes from the wrapped Qt libraries into
 its namespace."""
 
-__kits_to_load = [
-'Core',
-'Gui', 
-'Network', 
-'OpenGL', 
-'Sql',
-'Svg',
-'UiTools',
-'WebKit',
-'Xml', 
-'XmlPatterns'
-]
+__kits_to_load = [ @QT_PYTHON_WRAPPED_LIBRARIES@ ]
 
 # Set to True when debugging
 _CTK_VERBOSE_IMPORT = False
@@ -23,6 +12,6 @@ for kit in __kits_to_load:
    except ImportError as detail:
      if _CTK_VERBOSE_IMPORT:
        print detail
-   
+
 # Removing things the user shouldn't have to see.
 del __kits_to_load, _CTK_VERBOSE_IMPORT

+ 9 - 3
Libs/Scripting/Python/Core/Testing/Cpp/CMakeLists.txt

@@ -13,9 +13,15 @@ set(LIBRARY_NAME ${PROJECT_NAME})
 include_directories(${CMAKE_SOURCE_DIR}/Libs/Testing
                     ${CMAKE_CURRENT_BINARY_DIR})
 
-QT4_GENERATE_MOCS(
-  ctkAbstractPythonManagerTest.cpp
-  )
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_GENERATE_MOCS(
+    ctkAbstractPythonManagerTest.cpp
+    )
+else()
+  QT4_GENERATE_MOCS(
+    ctkAbstractPythonManagerTest.cpp
+    )
+endif()
 
 add_executable(${KIT}CppTests ${Tests})
 target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES})

+ 2 - 2
Libs/Scripting/Python/Core/ctkAbstractPythonManager.cpp

@@ -312,7 +312,7 @@ QStringList ctkAbstractPythonManager::pythonAttributes(const QString& pythonVari
   QStringList moduleList = module.split(".", QString::SkipEmptyParts);
   foreach(const QString& module, moduleList)
     {
-    object = PyDict_GetItemString(dict, module.toAscii().data());
+    object = PyDict_GetItemString(dict, module.toLatin1().data());
     if (prevObject) { Py_DECREF(prevObject); }
     if (!object)
       {
@@ -327,7 +327,7 @@ QStringList ctkAbstractPythonManager::pythonAttributes(const QString& pythonVari
     return QStringList();
     }
 
-//  PyObject* object = PyDict_GetItemString(dict, module.toAscii().data());
+//  PyObject* object = PyDict_GetItemString(dict, module.toLatin1().data());
 //  if (!object)
 //    {
 //    return QStringList();

+ 3 - 0
Libs/Scripting/Python/Core/ctkScriptingPythonCoreConfigure.h.in

@@ -9,12 +9,15 @@
 
 #cmakedefine CTK_PYTHONQT_WRAP_QTCORE
 #cmakedefine CTK_PYTHONQT_WRAP_QTGUI
+#cmakedefine CTK_PYTHONQT_WRAP_QTWIDGETS
 #cmakedefine CTK_PYTHONQT_WRAP_QTNETWORK
 #cmakedefine CTK_PYTHONQT_WRAP_QTOPENGL
+#cmakedefine CTK_PYTHONQT_WRAP_QTPRINTSUPPORT
 #cmakedefine CTK_PYTHONQT_WRAP_QTSQL
 #cmakedefine CTK_PYTHONQT_WRAP_QTSVG
 #cmakedefine CTK_PYTHONQT_WRAP_QTUITOOLS
 #cmakedefine CTK_PYTHONQT_WRAP_QTWEBKIT
+#cmakedefine CTK_PYTHONQT_WRAP_QTWEBKITWIDGETS
 #cmakedefine CTK_PYTHONQT_WRAP_QTXML
 #cmakedefine CTK_PYTHONQT_WRAP_QTXMLPATTERNS
 

+ 4 - 0
Libs/Scripting/Python/Core/ctk_library_options.cmake

@@ -10,11 +10,15 @@ set(ctk_library_options
   PYTHONQT_WRAP_QTALL:OFF
   PYTHONQT_WRAP_QTCORE:OFF
   PYTHONQT_WRAP_QTGUI:OFF
+  PYTHONQT_WRAP_QTWIDGETS:OFF
   PYTHONQT_WRAP_QTNETWORK:OFF
   PYTHONQT_WRAP_QTOPENGL:OFF
+  PYTHONQT_WRAP_QTPRINTSUPPORT:OFF
   PYTHONQT_WRAP_QTSQL:OFF
   PYTHONQT_WRAP_QTSVG:OFF
   PYTHONQT_WRAP_QTUITOOLS:OFF
   PYTHONQT_WRAP_QTWEBKIT:OFF
+  PYTHONQT_WRAP_QTWEBKITWIDGETS:OFF
   PYTHONQT_WRAP_QTXML:OFF
+  PYTHONQT_WRAP_QTXMLPATTERNS:OFF
   )

+ 2 - 0
Libs/Scripting/Python/Widgets/Plugins/ctkScriptingPythonWidgetsPlugins.cpp

@@ -24,4 +24,6 @@
 // CTK includes
 #include "ctkScriptingPythonWidgetsPlugins.h"
 
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
 Q_EXPORT_PLUGIN2(customwidgetplugin, ctkScriptingPythonWidgetsPlugins);
+#endif

+ 6 - 2
Libs/Scripting/Python/Widgets/Plugins/ctkScriptingPythonWidgetsPlugins.h

@@ -29,10 +29,14 @@
 #include "ctkPythonConsolePlugin.h"
 
 /// \class Group the plugins in one library
-class CTK_SCRIPTING_PYTHON_WIDGETS_PLUGINS_EXPORT ctkScriptingPythonWidgetsPlugins : 
-  public QObject, public QDesignerCustomWidgetCollectionInterface
+class CTK_SCRIPTING_PYTHON_WIDGETS_PLUGINS_EXPORT ctkScriptingPythonWidgetsPlugins
+  : public QObject
+  , public QDesignerCustomWidgetCollectionInterface
 {
   Q_OBJECT
+#if QT_VERSION >= 0x50000
+  Q_PLUGIN_METADATA(IID "org.commontk.Python")
+#endif
   Q_INTERFACES(QDesignerCustomWidgetCollectionInterface);
 
 public:

+ 6 - 4
Libs/Scripting/Python/Widgets/ctkPythonConsole.cpp

@@ -49,7 +49,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 =========================================================================*/
 
 // Qt includes
+#include <QAbstractItemView>
 #include <QCoreApplication>
+#include <QIcon>
 #include <QResizeEvent>
 #include <QScrollBar>
 #include <QStringListModel>
@@ -268,7 +270,7 @@ bool ctkPythonConsolePrivate::push(const QString& code)
   PyObject *res = PyObject_CallMethod(this->InteractiveConsole,
                                       const_cast<char*>("push"),
                                       const_cast<char*>("z"),
-                                      buffer.toAscii().data());
+                                      buffer.toLatin1().data());
   if (res)
     {
     int status = 0;
@@ -381,7 +383,7 @@ void ctkPythonConsole::initialize(ctkAbstractPythonManager* newPythonManager)
 //  d->printOutputMessage("\n");
 //  emit this->executing(true);
 ////   d->Interpreter->RunSimpleString(
-////     script.toAscii().data());
+////     script.toLatin1().data());
 //  emit this->executing(false);
 //  d->promptForInput();
 //}
@@ -397,7 +399,7 @@ QString ctkPythonConsole::ps1() const
 //----------------------------------------------------------------------------
 void ctkPythonConsole::setPs1(const QString& newPs1)
 {
-  PySys_SetObject(const_cast<char*>("ps1"), PyString_FromString(newPs1.toAscii().data()));
+  PySys_SetObject(const_cast<char*>("ps1"), PyString_FromString(newPs1.toLatin1().data()));
 }
 
 //----------------------------------------------------------------------------
@@ -411,7 +413,7 @@ QString ctkPythonConsole::ps2() const
 //----------------------------------------------------------------------------
 void ctkPythonConsole::setPs2(const QString& newPs2)
 {
-  PySys_SetObject(const_cast<char*>("ps2"), PyString_FromString(newPs2.toAscii().data()));
+  PySys_SetObject(const_cast<char*>("ps2"), PyString_FromString(newPs2.toLatin1().data()));
 }
 
 //----------------------------------------------------------------------------

+ 5 - 1
Libs/Visualization/VTK/Core/Testing/Cpp/CMakeLists.txt

@@ -42,7 +42,11 @@ set(KIT_HELPER_SRCS
   ctkVTKObjectTestHelper.cpp
   )
 
-QT4_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)
+else()
+  QT4_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)
+endif()
 
 #
 # Tests

+ 2 - 0
Libs/Visualization/VTK/Widgets/Plugins/ctkVTKWidgetsPlugins.cpp

@@ -24,4 +24,6 @@
 // CTK includes
 #include "ctkVTKWidgetsPlugins.h"
 
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
 Q_EXPORT_PLUGIN2(customwidgetplugin, ctkVTKWidgetsPlugins);
+#endif

+ 6 - 3
Libs/Visualization/VTK/Widgets/Plugins/ctkVTKWidgetsPlugins.h

@@ -43,11 +43,14 @@
 #include "ctkVTKThresholdWidgetPlugin.h"
 
 /// \class Group the plugins in one library
-class CTK_VISUALIZATION_VTK_WIDGETS_PLUGINS_EXPORT ctkVTKWidgetsPlugins :
-  public QObject,
-  public QDesignerCustomWidgetCollectionInterface
+class CTK_VISUALIZATION_VTK_WIDGETS_PLUGINS_EXPORT ctkVTKWidgetsPlugins
+  : public QObject
+  , public QDesignerCustomWidgetCollectionInterface
 {
   Q_OBJECT
+#if QT_VERSION >= 0x50000
+  Q_PLUGIN_METADATA(IID "org.commontk.VTKWidgets")
+#endif
   Q_INTERFACES(QDesignerCustomWidgetCollectionInterface);
 
 public:

+ 23 - 11
Libs/Visualization/VTK/Widgets/Testing/Cpp/CMakeLists.txt

@@ -94,19 +94,31 @@ if(CTK_USE_QTTESTING)
 endif()
 
 set(TEST_MOC_CPP)
-if(TEST_MOC_SOURCES)
-  QT4_WRAP_CPP(TEST_MOC_CPP ${TEST_MOC_SOURCES})
-endif()
-QT4_GENERATE_MOCS(
-  ctkVTKPropertyWidgetTest.cpp
-  )
-
 set(TEST_UI_CPP)
-if(TEST_UI_FORMS)
-  QT4_WRAP_UI(TEST_UI_CPP ${TEST_UI_FORMS})
-endif()
 set(Tests_RESOURCES_SRCS)
-QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  if(TEST_MOC_SOURCES)
+    QT5_WRAP_CPP(TEST_MOC_CPP ${TEST_MOC_SOURCES})
+  endif()
+  QT5_GENERATE_MOCS(
+    ctkVTKPropertyWidgetTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT5_WRAP_UI(TEST_UI_CPP ${TEST_UI_FORMS})
+  endif()
+  QT5_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+else()
+  if(TEST_MOC_SOURCES)
+    QT4_WRAP_CPP(TEST_MOC_CPP ${TEST_MOC_SOURCES})
+  endif()
+  QT4_GENERATE_MOCS(
+    ctkVTKPropertyWidgetTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT4_WRAP_UI(TEST_UI_CPP ${TEST_UI_FORMS})
+  endif()
+  QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+endif()
 
 add_executable(${KIT}CppTests ${Tests} ${TEST_MOC_CPP} ${TEST_UI_CPP} ${Tests_RESOURCES_SRCS})
 if(${VTK_VERSION_MAJOR} GREATER 5)

+ 5 - 1
Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.cpp

@@ -605,7 +605,7 @@ bool ctkVTKMagnifyView::eventFilter(QObject * obj, QEvent * event)
   Q_ASSERT(widget);
   Q_D(ctkVTKMagnifyView);
   Q_ASSERT(d->ObservedQVTKWidgets.contains(widget));
-  d->EventHandler.Widget = QWeakPointer<QVTKWidget>(widget);
+  d->EventHandler.Widget = widget;
 
   QEvent::Type eventType = event->type();
 
@@ -614,7 +614,11 @@ bool ctkVTKMagnifyView::eventFilter(QObject * obj, QEvent * event)
     {
     QMouseEvent * mouseEvent = static_cast<QMouseEvent *>(event);
     Q_ASSERT(mouseEvent);
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+    d->pushUpdatePixmapEvent(mouseEvent->localPos());
+#else
     d->pushUpdatePixmapEvent(mouseEvent->posF());
+#endif
     }
   // On enter, update the pixmap with the zoomed image (required for zooming when
   // widget is created with mouse already within it), and emit signal of enter event

+ 2 - 2
Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView_p.h

@@ -22,7 +22,7 @@
 #define __ctkVTKMagnifyView_p_h
 
 // Qt includes
-#include <QObject>
+#include <QPointer>
 class QPointF;
 class QTimerEvent;
 
@@ -67,7 +67,7 @@ protected:
   struct EventHandlerStruct
     {
     PendingEventType EventType;
-    QWeakPointer<QVTKWidget> Widget;
+    QPointer<QVTKWidget> Widget;
     QPointF Position;
     int UpdateInterval;
     int TimerId;

+ 4 - 1
Libs/Visualization/VTK/Widgets/target_libraries.cmake

@@ -8,4 +8,7 @@ set(target_libraries
   VTK_LIBRARIES
   CTKWidgets
   CTKVisualizationVTKCore
-  )
+  )
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  list(APPEND target_libraries Qt5Network_LIBRARIES Qt5WebKit_LIBRARIES)
+endif()

+ 10 - 2
Libs/Widgets/CMakeLists.txt

@@ -286,10 +286,12 @@ set(KIT_MOC_SRCS
   ctkWorkflowWidgetStep_p.h
   )
 
-QT4_GENERATE_MOCS(
+# Headers that should run through moc without adding
+# the generated cpp file to the source list
+set(KIT_GENERATE_MOC_SRCS
   ctkPathLineEdit.h
   ctkPathListWidget.h
-)
+  )
 
 # UI files
 set(KIT_UI_FORMS
@@ -404,15 +406,21 @@ if(CTK_USE_QTTESTING)
   list(APPEND KIT_target_libraries QtTesting)
 endif()
 
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  set(qt5_modules Qt5Widgets Qt5Xml Qt5OpenGL)
+endif()
+
 ctkMacroBuildLib(
   NAME ${PROJECT_NAME}
   EXPORT_DIRECTIVE ${KIT_export_directive}
   SRCS ${KIT_SRCS}
   MOC_SRCS ${KIT_MOC_SRCS}
+  GENERATE_MOC_SRCS ${KIT_GENERATE_MOC_SRCS}
   UI_FORMS ${KIT_UI_FORMS}
   TARGET_LIBRARIES ${KIT_target_libraries}
   RESOURCES ${KIT_resources}
   LIBRARY_TYPE ${CTK_LIBRARY_MODE}
+  QT5_MODULES ${qt5_modules}
   )
 
 if(CTK_WRAP_PYTHONQT_LIGHT)

+ 2 - 0
Libs/Widgets/Plugins/ctkWidgetsPlugins.cpp

@@ -24,4 +24,6 @@
 // CTK includes
 #include "ctkWidgetsPlugins.h"
 
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
 Q_EXPORT_PLUGIN2(customwidgetplugin, ctkWidgetsPlugins);
+#endif

+ 7 - 4
Libs/Widgets/Plugins/ctkWidgetsPlugins.h

@@ -69,12 +69,15 @@
 #include "ctkWorkflowWidgetStepPlugin.h"
 
 /// \class Group the plugins in one library
-class CTK_WIDGETS_PLUGINS_EXPORT ctkWidgetsPlugins : public QObject,
-      public QDesignerCustomWidgetCollectionInterface
+class CTK_WIDGETS_PLUGINS_EXPORT ctkWidgetsPlugins
+  : public QObject
+  , public QDesignerCustomWidgetCollectionInterface
 {
   Q_OBJECT
-  Q_INTERFACES(QDesignerCustomWidgetCollectionInterface);
-
+  Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
+#if (QT_VERSION >= 0x50000)
+  Q_PLUGIN_METADATA(IID "org.commontk.Widgets")
+#endif
 public:
   QList<QDesignerCustomWidgetInterface*> customWidgets() const
     {

+ 18 - 7
Libs/Widgets/Testing/Cpp/CMakeLists.txt

@@ -186,9 +186,7 @@ if(CTK_USE_QTTESTING)
   ctkQtTesting(Tests_SRCS Tests_MOC_SRCS Tests_UI_FORMS Tests_RESOURCES)
 endif()
 
-set(Tests_MOC_CPP)
-QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
-QT4_GENERATE_MOCS(
+set(Tests_MOC_CPPS
   ctkCoordinatesWidgetTest.cpp
   ctkCoordinatesWidgetValueProxyTest.cpp
   ctkDoubleRangeSliderTest.cpp
@@ -213,12 +211,25 @@ QT4_GENERATE_MOCS(
   ctkSliderWidgetTest.cpp
   ctkSliderWidgetValueProxyTest.cpp
   )
+
+set(Tests_MOC_CPP)
 set(Tests_UI_CPP)
-if(TEST_UI_FORMS)
-  QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
-endif()
 set(Tests_RESOURCES_SRCS)
-QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  qt5_wrap_cpp(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  qt5_generate_mocs(${Tests_MOC_CPPS})
+  if(TEST_UI_FORMS)
+    qt5_wrap_ui(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  qt5_add_resources(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+else()
+  QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  QT4_GENERATE_MOCS(${Tests_MOC_CPPS})
+  if(TEST_UI_FORMS)
+    QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+endif()
 
 add_executable(${KIT}CppTests ${Tests} ${Tests_SRCS} ${Tests_MOC_CPP} ${Tests_UI_CPP} ${Tests_RESOURCES_SRCS})
 target_link_libraries(${KIT}CppTests ${LIBRARY_NAME})

+ 7 - 2
Libs/Widgets/Testing/Cpp/ctkCheckableComboBoxTest1.cpp

@@ -21,9 +21,12 @@
 // Qt includes
 #include <QDebug>
 #include <QApplication>
-#include <QCleanlooksStyle>
 #include <QTimer>
 
+#if (QT_VERSION < 0x50000)
+#include <QCleanlooksStyle>
+#endif
+
 // CTK includes
 #include <ctkCheckableComboBox.h>
 
@@ -36,7 +39,9 @@ int ctkCheckableComboBoxTest1(int argc, char * argv [] )
 {
   // QCleanlooksStyle is the only style that doesn't show the checkboxes by
   // default. Test it with it
+#if (QT_VERSION < 0x50000)
   QApplication::setStyle(new QCleanlooksStyle);
+#endif
   QApplication app(argc, argv);
 
   ctkCheckableComboBox comboBox;
@@ -102,6 +107,6 @@ int ctkCheckableComboBoxTest1(int argc, char * argv [] )
     {
     QTimer::singleShot(200, &app, SLOT(quit()));
     }
-  
+
   return app.exec();
 }

+ 31 - 13
Libs/Widgets/Testing/Cpp/ctkCheckableHeaderViewTest1.cpp

@@ -57,13 +57,13 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
   row2[0]->setText("checkable");
   model.appendRow(row2);
 
-  // items are unchecked by default 
+  // items are unchecked by default
   if (row0[0]->checkState() != Qt::Unchecked ||
       row1[0]->checkState() != Qt::Unchecked ||
       row2[0]->checkState() != Qt::Unchecked)
     {
     std::cerr << "QStandardItem default failed: "
-	      << static_cast<int>(row0[0]->checkState()) << " "
+        << static_cast<int>(row0[0]->checkState()) << " "
               << static_cast<int>(row1[0]->checkState()) << " "
               << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
@@ -76,25 +76,43 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
   model.setHeaderData(0, Qt::Horizontal, Qt::Checked, Qt::CheckStateRole);
 
   QHeaderView* previousHeaderView = table.horizontalHeader();
+#if (QT_VERSION >= 0x50000)
+  bool oldClickable = previousHeaderView->sectionsClickable();
+#else
   bool oldClickable = previousHeaderView->isClickable();
+#endif
 
   ctkCheckableHeaderView* headerView =
     new ctkCheckableHeaderView(Qt::Horizontal, &table);
+#if (QT_VERSION >= 0x50000)
+  headerView->setSectionsClickable(oldClickable);
+  headerView->setSectionsMovable(previousHeaderView->sectionsMovable());
+#else
   headerView->setClickable(oldClickable);
   headerView->setMovable(previousHeaderView->isMovable());
+#endif
   headerView->setHighlightSections(previousHeaderView->highlightSections());
   // propagatetoitems is true by default
   //headerView->setPropagateToItems(true);
 
   // sets the model to the headerview
   table.setHorizontalHeader(headerView);
-  
+
+#if (QT_VERSION >= 0x50000)
+  if (headerView->sectionsClickable() != oldClickable)
+    {
+    std::cerr << "ctkCheckableHeaderView::setSectionClickable() failed: "
+              << headerView->sectionsClickable() << std::endl;
+    return EXIT_FAILURE;
+    }
+#else
   if (headerView->isClickable() != oldClickable)
     {
     std::cerr << "ctkCheckableHeaderView::setClickable() failed: "
               << headerView->isClickable() << std::endl;
     return EXIT_FAILURE;
     }
+#endif
   // As propagateToItems is true, once the model is set to the headerview,
   // the checkable header is updated from the check state of all the items
   // all the items are unchecked by default, so the header becomes unchecked
@@ -105,7 +123,7 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
     {
     std::cerr << "ctkCheckableHeaderView::checkstate() failed: "
               << static_cast<int>(headerView->checkState(0)) << " "
-	      << static_cast<int>(row0[0]->checkState()) << " "
+        << static_cast<int>(row0[0]->checkState()) << " "
               << static_cast<int>(row1[0]->checkState()) << " "
               << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
@@ -121,7 +139,7 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
 
   QFocusEvent focus(QEvent::FocusIn,Qt::TabFocusReason);
   headerView->eventFilter(headerView, &focus);
-  
+
   if (headerView->checkableModelHelper()->propagateDepth() == 0)
     {
     std::cerr << "ctkCheckableHeaderView::propagateDepth() failed: "
@@ -142,7 +160,7 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
     {
     std::cerr << "ctkCheckableHeaderView::propagateToItems() failed: "
               << static_cast<int>(headerView->checkState(0)) << " "
-	      << static_cast<int>(row0[0]->checkState()) << " "
+        << static_cast<int>(row0[0]->checkState()) << " "
               << static_cast<int>(row1[0]->checkState()) << " "
               << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
@@ -150,7 +168,7 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
 
   // check the header
   headerView->checkableModelHelper()->toggleHeaderCheckState(0);
-  
+
   // make sure it didn't uncheck the checkable items
   if (headerView->checkState(0) != Qt::Checked ||
       row0[0]->checkState() != Qt::Unchecked ||
@@ -159,7 +177,7 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
     {
     std::cerr << __LINE__ << " ctkCheckableHeaderView::toggleCheckState() failed: "
               << static_cast<int>(headerView->checkState(0)) << " "
-	      << static_cast<int>(row0[0]->checkState()) << " "
+        << static_cast<int>(row0[0]->checkState()) << " "
               << static_cast<int>(row1[0]->checkState()) << " "
               << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
@@ -198,7 +216,7 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
     }
 
   row0[0]->setCheckState(Qt::Unchecked);
-  
+
   if (headerView->checkState(0) != Qt::Unchecked ||
       row0[0]->checkState() != Qt::Unchecked ||
       row1[0]->checkState() != Qt::Unchecked ||
@@ -213,7 +231,7 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
     }
 
   row1[0]->setCheckState(Qt::Checked);
-  
+
     // make sure it didn't uncheck the checkable items
   if (headerView->checkState(0) != Qt::PartiallyChecked ||
       row0[0]->checkState() != Qt::Unchecked ||
@@ -229,7 +247,7 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
     }
 
   row1[0]->setCheckState(Qt::Checked);
-  
+
   // make sure it didn't check the checkable items
   if (headerView->checkState(0) != Qt::PartiallyChecked ||
       row0[0]->checkState() != Qt::Unchecked ||
@@ -262,7 +280,7 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
     }
 
   headerView->setCheckState(0, Qt::Unchecked);
-    
+
   if (headerView->checkState(0) != Qt::Unchecked ||
       row0[0]->checkState() != Qt::Unchecked ||
       row1[0]->checkState() != Qt::Unchecked ||
@@ -282,6 +300,6 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
     {
     QTimer::singleShot(500, &app, SLOT(quit()));
     }
-  
+
   return app.exec();
 }

+ 11 - 2
Libs/Widgets/Testing/Cpp/ctkCheckableHeaderViewTest2.cpp

@@ -65,11 +65,20 @@ int ctkCheckableHeaderViewTest2(int argc, char * argv [] )
   model.setHeaderData(0, Qt::Horizontal, Qt::Checked, Qt::CheckStateRole);
 
   QHeaderView* previousHeaderView = view.header();
+#if (QT_VERSION >= 0x50000)
+  bool oldClickable = previousHeaderView->sectionsClickable();
+#else
   bool oldClickable = previousHeaderView->isClickable();
+#endif
 
-  ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(Qt::Horizontal, &view);  
+  ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(Qt::Horizontal, &view);
+#if (QT_VERSION >= 0x50000)
+  headerView->setSectionsClickable(oldClickable);
+  headerView->setSectionsMovable(previousHeaderView->sectionsMovable());
+#else
   headerView->setClickable(oldClickable);
   headerView->setMovable(previousHeaderView->isMovable());
+#endif
   headerView->setHighlightSections(previousHeaderView->highlightSections());
   headerView->checkableModelHelper()->setPropagateDepth(-1);
   headerView->checkableModelHelper()->setForceCheckability(true);
@@ -84,6 +93,6 @@ int ctkCheckableHeaderViewTest2(int argc, char * argv [] )
     {
     QTimer::singleShot(500, &app, SLOT(quit()));
     }
-  
+
   return app.exec();
 }

+ 4 - 0
Libs/Widgets/Testing/Cpp/ctkColorDialogTest1.cpp

@@ -90,7 +90,11 @@ int ctkColorDialogTest1(int argc, char * argv [] )
   // the following is only in interactive mode
   if (argc < 2 || QString(argv[1]) != "-I" )
     {
+#if (QT_VERSION >= 0x50000)
+    QTest::qWaitForWindowActive(&colorDialog);
+#else
     QTest::qWaitForWindowShown(&colorDialog);
+#endif
     colorDialog.accept();
     return EXIT_SUCCESS;
     }

+ 4 - 0
Libs/Widgets/Testing/Cpp/ctkDoubleRangeSliderTest.cpp

@@ -45,7 +45,11 @@ void ctkDoubleRangeSliderTester::testUI()
 {
   ctkDoubleRangeSlider slider;
   slider.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&slider);
+#else
   QTest::qWaitForWindowShown(&slider);
+#endif
   // qApp->exec();
 }
 

+ 4 - 0
Libs/Widgets/Testing/Cpp/ctkDoubleSliderTest.cpp

@@ -45,7 +45,11 @@ void ctkDoubleSliderTester::testUI()
 {
   ctkDoubleSlider slider;
   slider.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&slider);
+#else
   QTest::qWaitForWindowShown(&slider);
+#endif
   // qApp->exec();
 }
 

+ 4 - 0
Libs/Widgets/Testing/Cpp/ctkDoubleSpinBoxTest.cpp

@@ -81,7 +81,11 @@ void ctkDoubleSpinBoxTester::testUI()
   spinBox.setPrefix("A: ");
   spinBox.setSetMode(ctkDoubleSpinBox::SetAlways);
   spinBox.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&spinBox);
+#else
   QTest::qWaitForWindowShown(&spinBox);
+#endif
   QObject::connect(&spinBox, SIGNAL(valueChanged(double)),
                    &spinBox, SLOT(setValue(double)), Qt::QueuedConnection);
 

+ 5 - 0
Libs/Widgets/Testing/Cpp/ctkExpandableWidgetTest1.cpp

@@ -29,7 +29,10 @@
 #include <QTimer>
 #include <QTreeView>
 #include <QVBoxLayout>
+
+#if (QT_VERSION < 0x50000)
 #include <QPlastiqueStyle>
+#endif
 
 // CTK includes
 #include "ctkExpandableWidget.h"
@@ -41,7 +44,9 @@
 //-----------------------------------------------------------------------------
 int ctkExpandableWidgetTest1(int argc, char * argv [] )
 {
+#if (QT_VERSION < 0x50000)
   QApplication::setStyle(new QPlastiqueStyle);
+#endif
   QApplication app(argc, argv);
 
   QWidget topLevel;

+ 9 - 0
Libs/Widgets/Testing/Cpp/ctkMatrixWidgetTest.cpp

@@ -45,7 +45,11 @@ void ctkMatrixWidgetTester::testUI()
   matrix.setMaximum(100.);
 
   matrix.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&matrix);
+#else
   QTest::qWaitForWindowShown(&matrix);
+#endif
   //qApp->exec();
 }
 
@@ -59,7 +63,12 @@ void ctkMatrixWidgetTester::testDecimals()
   matrix.setValue(0, 0, 1.000000001);
 
   matrix.show();
+
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&matrix);
+#else
   QTest::qWaitForWindowShown(&matrix);
+#endif
   //qApp->exec();
 
   QCOMPARE(matrix.value(0, 0), 1.000000001);

+ 4 - 0
Libs/Widgets/Testing/Cpp/ctkPathListWidgetWithButtonsTest.cpp

@@ -67,7 +67,11 @@ void ctkPathListWidgetWithButtonsTester::testButtons()
   topLevel.layout()->addWidget(&pathListButtons);
 
   topLevel.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&topLevel);
+#else
   QTest::qWaitForWindowShown(&topLevel);
+#endif
 
   struct CloseModalDialog : public QRunnable
   {

+ 0 - 1
Libs/Widgets/Testing/Cpp/ctkProxyStyleTest1.cpp

@@ -21,7 +21,6 @@
 // Qt includes
 #include <QApplication>
 #include <QDebug>
-#include <QPlastiqueStyle>
 #include <QProxyStyle>
 #include <QTimer>
 #include <QVBoxLayout>

+ 10 - 3
Libs/Widgets/Testing/Cpp/ctkPushButtonTest.cpp

@@ -20,12 +20,13 @@
 
 // Qt includes
 #include <QApplication>
-#include <QCleanlooksStyle>
 #include <QHBoxLayout>
-#include <QPlastiqueStyle>
 #include <QSignalSpy>
 #include <QTimer>
-#include <QWindowsStyle>
+
+#if (QT_VERSION < 0x50000)
+#include <QCleanlooksStyle>
+#endif
 
 // CTK includes
 #include "ctkPushButton.h"
@@ -44,7 +45,9 @@ private slots:
 // ----------------------------------------------------------------------------
 void ctkPushButtonTester::testDefaults()
 {
+#if (QT_VERSION < 0x50000)
   QApplication::setStyle( new QCleanlooksStyle );
+#endif
 
   ctkPushButton button("text");
 
@@ -52,7 +55,11 @@ void ctkPushButtonTester::testDefaults()
   QCOMPARE(button.iconAlignment(), Qt::AlignLeft|Qt::AlignVCenter);
 
   button.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&button);
+#else
   QTest::qWaitForWindowShown(&button);
+#endif
   //qApp->exec();
 }
 

+ 9 - 1
Libs/Widgets/Testing/Cpp/ctkRangeSliderTest.cpp

@@ -20,7 +20,9 @@
 
 // Qt includes
 #include <QApplication>
+#if (QT_VERSION < 0x50000)
 #include <QCleanlooksStyle>
+#endif
 #include <QString>
 #include <QStyle>
 #include <QStyleOptionSlider>
@@ -52,7 +54,9 @@ private slots:
 void ctkRangeSliderTester::initTestCase()
 {
   // Mouse position on handles does not with with gtk style.
+#if (QT_VERSION < 0x50000)
   QApplication::setStyle(new QCleanlooksStyle());
+#endif
 }
 
 // ----------------------------------------------------------------------------
@@ -112,7 +116,7 @@ void ctkRangeSliderTester::testGrooveMouseEvents()
   QRect sliderHandleSize = rangeSlider.style()->subControlRect(
     QStyle::CC_Slider, &option, QStyle::SC_SliderHandle, &rangeSlider );
   rangeSlider.resize(100 + sliderHandleSize.width(), 20);
-  
+
   QFETCH(int, moveInPx);
   QFETCH(int, expectedMinValue);
   QFETCH(int, expectedMaxValue);
@@ -159,7 +163,11 @@ void ctkRangeSliderTester::testHandleMouseEvents()
   rangeSlider.resize(100 + sliderHandleSize.width(), 20);
 
   rangeSlider.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&rangeSlider);
+#else
   QTest::qWaitForWindowShown(&rangeSlider);
+#endif
 
   QFETCH(bool, minHandle);
   QFETCH(bool, symmetricMoves);

+ 4 - 0
Libs/Widgets/Testing/Cpp/ctkRangeWidgetTest.cpp

@@ -58,7 +58,11 @@ void ctkRangeWidgetTester::testUI()
 {
   ctkRangeWidget rangeWidget;
   rangeWidget.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&rangeWidget);
+#else
   QTest::qWaitForWindowShown(&rangeWidget);
+#endif
   //qApp->exec();
 }
 

+ 4 - 0
Libs/Widgets/Testing/Cpp/ctkSearchBoxTest.cpp

@@ -41,7 +41,11 @@ void ctkSearchBoxTester::testSignals()
 {
   ctkSearchBox searchBox;
   searchBox.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&searchBox);
+#else
   QTest::qWaitForWindowShown(&searchBox);
+#endif
 
   QSignalSpy textEditedSpy(&searchBox, SIGNAL(textEdited(QString)));
   QSignalSpy textChangedSpy(&searchBox, SIGNAL(textChanged(QString)));

+ 12 - 0
Libs/Widgets/Testing/Cpp/ctkSliderWidgetTest.cpp

@@ -66,7 +66,11 @@ void ctkSliderWidgetTester::testUI()
   slider.setValue(26.2110001);
   slider.setPrefix("A: ");
   slider.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&slider);
+#else
   QTest::qWaitForWindowShown(&slider);
+#endif
   QObject::connect(&slider, SIGNAL(valueChanged(double)),
                    &slider, SLOT(setValue(double)), Qt::QueuedConnection);
 
@@ -160,7 +164,11 @@ void ctkSliderWidgetTester::testDecimalsByShortcuts()
   slider.setValue( -2.145195007324205 );
 
   slider.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&slider);
+#else
   QTest::qWaitForWindowShown(&slider);
+#endif
   //qApp->exec();
   //QSignalSpy spy(&slider, SIGNAL(decimalsChanged(int)));
 
@@ -181,7 +189,11 @@ void ctkSliderWidgetTester::testValueChangedWithNoTracking()
   slider.setValue((slider.maximum() + slider.minimum()) / 2);
 
   slider.show();
+#if (QT_VERSION >= 0x50000)
+  QTest::qWaitForWindowActive(&slider);
+#else
   QTest::qWaitForWindowShown(&slider);
+#endif
 
   slider.setTracking(false);
   QSignalSpy spy(&slider, SIGNAL(valueChanged(double)));

+ 12 - 13
Libs/Widgets/ctkBasePopupWidget.cpp

@@ -79,7 +79,6 @@ QGradient* duplicateGradient(const QGradient* gradient)
 ctkBasePopupWidgetPrivate::ctkBasePopupWidgetPrivate(ctkBasePopupWidget& object)
   :q_ptr(&object)
 {
-  this->BaseWidget = 0;
   this->Effect = ctkBasePopupWidget::ScrollEffect;
   this->EffectDuration = 333; // in ms
   this->EffectAlpha = 1.;
@@ -168,7 +167,7 @@ QWidgetList ctkBasePopupWidgetPrivate::focusWidgets(bool onlyVisible)const
     {
     res << const_cast<ctkBasePopupWidget*>(q);
     }
-  if (this->BaseWidget && (!onlyVisible || this->BaseWidget->isVisible()))
+  if (!this->BaseWidget.isNull() && (!onlyVisible || this->BaseWidget->isVisible()))
     {
     res << this->BaseWidget;
     }
@@ -227,7 +226,7 @@ bool ctkBasePopupWidgetPrivate::isAncestorOf(const QWidget* ancestor, const QWid
 void ctkBasePopupWidgetPrivate::setupPopupPixmapWidget()
 {
   Q_Q(ctkBasePopupWidget);
-  this->PopupPixmapWidget->setAlignment(this->pixmapAlignment());  
+  this->PopupPixmapWidget->setAlignment(this->pixmapAlignment());
   QPixmap pixmap;
   if (q->testAttribute(Qt::WA_TranslucentBackground))
     {
@@ -303,7 +302,7 @@ QRect ctkBasePopupWidgetPrivate::closedGeometry(QRect openGeom)const
 // -------------------------------------------------------------------------
 QRect ctkBasePopupWidgetPrivate::baseGeometry()const
 {
-  if (!this->BaseWidget)
+  if (this->BaseWidget.isNull())
     {
     return QRect();
     }
@@ -315,7 +314,7 @@ QRect ctkBasePopupWidgetPrivate::baseGeometry()const
 QPoint ctkBasePopupWidgetPrivate::mapToGlobal(const QPoint& baseWidgetPoint)const
 {
   QPoint mappedPoint = baseWidgetPoint;
-  if (this->BaseWidget && this->BaseWidget->parentWidget())
+  if (!this->BaseWidget.isNull() && this->BaseWidget->parentWidget())
     {
     mappedPoint = this->BaseWidget->parentWidget()->mapToGlobal(mappedPoint);
     }
@@ -337,7 +336,7 @@ QRect ctkBasePopupWidgetPrivate::desiredOpenGeometry(QRect baseGeometry)const
     {
     size = q->sizeHint();
     }
-  
+
   if (baseGeometry.isNull())
     {
     return QRect(q->pos(), size);
@@ -438,7 +437,7 @@ void ctkBasePopupWidgetPrivate::hideAll()
   // Before hiding, transfer the active window flag to its parent, this will
   // prevent the application to send a ApplicationDeactivate signal that
   // doesn't need to be done.
-  if (q->isActiveWindow() && this->BaseWidget)
+  if (q->isActiveWindow() && !this->BaseWidget.isNull())
     {
     qApp->setActiveWindow(this->BaseWidget->window());
     }
@@ -494,13 +493,13 @@ QWidget* ctkBasePopupWidget::baseWidget()const
 void ctkBasePopupWidget::setBaseWidget(QWidget* widget)
 {
   Q_D(ctkBasePopupWidget);
-  if (d->BaseWidget)
+  if (!d->BaseWidget.isNull())
     {
     //disconnect(d->BaseWidget, SIGNAL(destroyed(QObject*)),
     //           this, SLOT(onBaseWidgetDestroyed()));
     }
   d->BaseWidget = widget;
-  if (d->BaseWidget)
+  if (!d->BaseWidget.isNull())
     {
     //connect(d->BaseWidget, SIGNAL(destroyed(QObject*)),
     //        this, SLOT(onBaseWidgetDestroyed()));
@@ -696,10 +695,10 @@ void ctkBasePopupWidget::paintEvent(QPaintEvent* event)
 void ctkBasePopupWidget::showPopup()
 {
   Q_D(ctkBasePopupWidget);
-  
+
   if ((this->isVisible() &&
        d->currentAnimation()->state() == QAbstractAnimation::Stopped) ||
-      (d->BaseWidget && !d->BaseWidget->isVisible()))
+      (!d->BaseWidget.isNull() && !d->BaseWidget->isVisible()))
     {
     return;
     }
@@ -717,7 +716,7 @@ void ctkBasePopupWidget::showPopup()
   QRect closedGeometry = d->closedGeometry();
 
   d->currentAnimation()->setDirection(QAbstractAnimation::Forward);
-  
+
   switch(d->Effect)
     {
     case WindowOpacityFadeEffect:
@@ -787,7 +786,7 @@ void ctkBasePopupWidget::hidePopup()
       d->PopupPixmapWidget->show();
       if (this->isActiveWindow())
         {
-        qApp->setActiveWindow(d->BaseWidget ? d->BaseWidget->window() : 0);
+        qApp->setActiveWindow(!d->BaseWidget.isNull() ? d->BaseWidget->window() : 0);
         }
       this->hide();
       break;

+ 3 - 2
Libs/Widgets/ctkBasePopupWidget_p.h

@@ -22,8 +22,9 @@
 #define __ctkBasePopupWidget_p_h
 
 // Qt includes
-class QPropertyAnimation;
+#include <QPointer>
 class QLabel;
+class QPropertyAnimation;
 
 // CTK includes
 #include "ctkBasePopupWidget.h"
@@ -85,7 +86,7 @@ public:
   void hideAll();
 
 protected:
-  QWidget* BaseWidget;
+  QPointer<QWidget> BaseWidget;
 
   double EffectAlpha;
 

+ 1 - 2
Libs/Widgets/ctkButtonGroup.cpp

@@ -18,10 +18,9 @@
 
 =========================================================================*/
 
-//Qt includes  
+//Qt includes
 #include <QAbstractButton>
 #include <QDebug>
-#include <QWeakPointer>
 
 // CTK includes
 #include "ctkButtonGroup.h"

+ 0 - 1
Libs/Widgets/ctkCheckableComboBox.cpp

@@ -21,7 +21,6 @@
 // Qt includes
 #include <QApplication>
 #include <QAbstractItemView>
-#include <QCleanlooksStyle>
 #include <QDebug>
 #include <QDesktopWidget>
 #include <QItemDelegate>

+ 2 - 2
Libs/Widgets/ctkCheckableHeaderView.cpp

@@ -406,7 +406,7 @@ void ctkCheckableHeaderView::initStyleSectionOption(QStyleOptionHeader *option,
     }
   QVariant foregroundBrush = this->model()->headerData(section, this->orientation(),
                                                   Qt::ForegroundRole);
-  if (qVariantCanConvert<QBrush>(foregroundBrush))
+  if (foregroundBrush.canConvert<QBrush>())
     {
     option->palette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(foregroundBrush));
     }
@@ -414,7 +414,7 @@ void ctkCheckableHeaderView::initStyleSectionOption(QStyleOptionHeader *option,
   //QPointF oldBO = painter->brushOrigin();
   QVariant backgroundBrush = this->model()->headerData(section, this->orientation(),
                                                   Qt::BackgroundRole);
-  if (qVariantCanConvert<QBrush>(backgroundBrush)) 
+  if (backgroundBrush.canConvert<QBrush>())
     {
     option->palette.setBrush(QPalette::Button, qvariant_cast<QBrush>(backgroundBrush));
     option->palette.setBrush(QPalette::Window, qvariant_cast<QBrush>(backgroundBrush));

+ 0 - 1
Libs/Widgets/ctkCheckablePushButton.cpp

@@ -20,7 +20,6 @@
 
 // Qt includes
 #include <QApplication>
-#include <QCleanlooksStyle>
 #include <QDebug>
 #include <QDesktopWidget>
 #include <QLayout>

+ 5 - 1
Libs/Widgets/ctkCollapsibleButton.cpp

@@ -20,7 +20,9 @@
 
 // Qt includes
 #include <QApplication>
-#include <QCleanlooksStyle>
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
+# include <QCleanlooksStyle>
+#endif
 #include <QDebug>
 #include <QLayout>
 #include <QMouseEvent>
@@ -628,11 +630,13 @@ void ctkCollapsibleButton::paintEvent(QPaintEvent * _event)
   fopt.init(this);
   // 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)
   if (qobject_cast<QCleanlooksStyle*>(this->style()) != 0)
     {
     fopt.rect.setTop(buttonHeight - 1);
     }
   else
+#endif
     {
     fopt.rect.setTop(buttonHeight);
     }

+ 1 - 0
Libs/Widgets/ctkConsole.cpp

@@ -54,6 +54,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <QClipboard>
 #include <QCompleter>
 #include <QKeyEvent>
+#include <QMimeData>
 #include <QPointer>
 #include <QTextCursor>
 #include <QVBoxLayout>

+ 2 - 2
Libs/Widgets/ctkCoordinatesWidget_p.h

@@ -22,7 +22,7 @@
 #define __ctkCoordinatesWidget_p_h
 
 // Qt includes
-#include <QWeakPointer>
+#include <QPointer>
 
 // CTK includes
 #include "ctkCoordinatesWidget.h"
@@ -72,7 +72,7 @@ public:
   double* Coordinates;
   QList<int> LastUserEditedCoordinates;
   bool    ChangingDecimals;
-  QWeakPointer<ctkValueProxy> Proxy;
+  QPointer<ctkValueProxy> Proxy;
 
 private:
   Q_DISABLE_COPY(ctkCoordinatesWidgetPrivate);

+ 2 - 2
Libs/Widgets/ctkDoubleRangeSlider.cpp

@@ -21,8 +21,8 @@
 // Qt includes
 #include <QDebug>
 #include <QHBoxLayout>
+#include <QPointer>
 #include <QVariant>
-#include <QWeakPointer>
 
 // CTK includes
 #include "ctkRangeSlider.h"
@@ -65,7 +65,7 @@ public:
   double MinValue;
   double MaxValue;
 
-  QWeakPointer<ctkValueProxy> Proxy;
+  QPointer<ctkValueProxy> Proxy;
 
 private:
   Q_DISABLE_COPY(ctkDoubleRangeSliderPrivate);

+ 2 - 1
Libs/Widgets/ctkDoubleSlider.cpp

@@ -22,6 +22,7 @@
 #include <QDebug>
 #include <QHBoxLayout>
 #include <QHelpEvent>
+#include <QPointer>
 #include <QStyle>
 #include <QStyleOptionSlider>
 #include <QToolTip>
@@ -77,7 +78,7 @@ public:
   double      PageStep;
   double      Value;
   /// Converts input value with displayed value
-  QWeakPointer<ctkValueProxy> Proxy;
+  QPointer<ctkValueProxy> Proxy;
 };
 
 // --------------------------------------------------------------------------

+ 2 - 2
Libs/Widgets/ctkDoubleSpinBox_p.h

@@ -23,7 +23,7 @@
 
 // Qt includes
 #include <QDoubleSpinBox>
-#include <QWeakPointer>
+#include <QPointer>
 class ctkDoubleSpinBoxPrivate;
 class ctkValueProxy;
 
@@ -100,7 +100,7 @@ public:
   mutable QSize CachedSizeHint;
   bool ForceInputValueUpdate;
 
-  QWeakPointer<ctkValueProxy> Proxy;
+  QPointer<ctkValueProxy> Proxy;
 
   void init();
   /// Compare two double previously rounded according to the number of decimals

+ 9 - 1
Libs/Widgets/ctkIconEnginePlugin.cpp

@@ -35,7 +35,11 @@ public:
 
 //------------------------------------------------------------------------------
 ctkIconEnginePlugin::ctkIconEnginePlugin(QObject* parentObject)
- :QIconEnginePluginV2(parentObject)
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  : QIconEnginePlugin(parentObject)
+#else
+  : QIconEnginePluginV2(parentObject)
+#endif
   , d_ptr(new ctkIconEnginePluginPrivate)
 {
 }
@@ -46,7 +50,11 @@ ctkIconEnginePlugin::~ctkIconEnginePlugin()
 }
 
 //------------------------------------------------------------------------------
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+QIconEngine* ctkIconEnginePlugin::create(const QString& fileName)
+#else
 QIconEngineV2* ctkIconEnginePlugin::create(const QString& fileName)
+#endif
 {
   Q_D(ctkIconEnginePlugin);
   Q_UNUSED(fileName);

+ 10 - 8
Libs/Widgets/ctkIconEnginePlugin.h

@@ -21,14 +21,14 @@
 #ifndef __ctkIconEnginePlugin_h
 #define __ctkIconEnginePlugin_h
 
+#include "ctkWidgetsExport.h"
 // Qt includes
-#include <QIconEngineV2>
-#include <QIconEnginePluginV2>
+# include <QIconEngine>
+# include <QIconEnginePlugin>
 
 // CTK includes
 #include "ctkPimpl.h"
 #include "ctkPixmapIconEngine.h"
-#include "ctkWidgetsExport.h"
 
 class ctkIconEnginePluginPrivate;
 class ctkIconEnginePrivate;
@@ -42,14 +42,16 @@ class ctkIconEnginePrivate;
 /// where the plugin must be located in "MyApp-build/plugins/iconengines"
 /// don't forget to declare in the cpp file:
 ///   Q_EXPORT_PLUGIN2(yourpluginName, ctkIconEnginePlugin)
-class CTK_WIDGETS_EXPORT ctkIconEnginePlugin: public QIconEnginePluginV2
+class CTK_WIDGETS_EXPORT ctkIconEnginePlugin
+  : public QIconEnginePlugin
 {
   Q_OBJECT;
 public:
   ctkIconEnginePlugin(QObject* parent = 0);
   virtual ~ctkIconEnginePlugin();
 
-  virtual QIconEngineV2* create(const QString& filename=QString());
+  virtual QIconEngine* create(const QString& filename);
+
   /// Support all the Qt image formats by default
   virtual QStringList keys()const;
 
@@ -87,7 +89,7 @@ private:
 /// any icon in a different directory:
 /// \code
 ///  ctkIconEngine* autoIconEngine;
-///  autoIconEngine->setSizeDirectories(QStringList() << "Large" << "Small"; 
+///  autoIconEngine->setSizeDirectories(QStringList() << "Large" << "Small";
 ///  QIcon editIcon(autoIconEngine);
 ///  editIcon.addFile(":/Icons/Small/edit.png");
 /// \endcode
@@ -111,10 +113,10 @@ public:
   QStringList sizeDirectories()const;
 
   virtual QString key()const;
- 
+
 protected:
   QScopedPointer<ctkIconEnginePrivate> d_ptr;
- 
+
 private:
   Q_DECLARE_PRIVATE(ctkIconEngine);
   Q_DISABLE_COPY(ctkIconEngine);

+ 15 - 15
Libs/Widgets/ctkMaterialPropertyPreviewLabel.cpp

@@ -40,15 +40,15 @@ protected:
   ctkMaterialPropertyPreviewLabel* const q_ptr;
 public:
   ctkMaterialPropertyPreviewLabelPrivate(ctkMaterialPropertyPreviewLabel& object);
-  
+
   QColor Color;
   double Opacity;
- 
+
   double Ambient;
   double Diffuse;
   double Specular;
   double SpecularPower;
- 
+
   double GridOpacity;
 };
 
@@ -62,7 +62,7 @@ ctkMaterialPropertyPreviewLabelPrivate::ctkMaterialPropertyPreviewLabelPrivate(c
   this->Diffuse = 1.0;
   this->Specular = 0.0;
   this->SpecularPower = 1;
-  
+
   this->GridOpacity = 0.6;
 }
 
@@ -89,7 +89,7 @@ ctkMaterialPropertyPreviewLabel::ctkMaterialPropertyPreviewLabel(
   d->Ambient = ambient;
   d->Diffuse = diffuse;
   d->Specular = specular;
-  d->SpecularPower = specularPower;  
+  d->SpecularPower = specularPower;
 }
 
 //-----------------------------------------------------------------------------
@@ -221,7 +221,7 @@ void ctkMaterialPropertyPreviewLabel::paintEvent(QPaintEvent* event)
   QRect cr = this->contentsRect();
   QImage image(cr.size(), QImage::Format_ARGB32_Premultiplied);
   this->draw(image);
-  
+
   QPainter widgetPainter(this);
   this->drawFrame(&widgetPainter);
   widgetPainter.drawImage(cr.left(), cr.top(), image);
@@ -239,7 +239,7 @@ void ctkMaterialPropertyPreviewLabel::draw(QImage& image)
   qreal specular_power = d->SpecularPower;
 
   int size = qMin(image.width(), image.height());
-  int size8 = qMax(size / 8, 1); 
+  int size8 = qMax(size / 8, 1);
   qreal size2 = 0.5 * size;
   qreal radius2 = size2*size2 - 1;
 
@@ -250,7 +250,7 @@ void ctkMaterialPropertyPreviewLabel::draw(QImage& image)
       {
       int iGrid = i / size8;
       int jGrid = j / size8;
-      
+
       if (((iGrid / 2) * 2 == iGrid &&
            (jGrid / 2) * 2 == jGrid) ||
           ((iGrid / 2) * 2 != iGrid &&
@@ -272,7 +272,7 @@ void ctkMaterialPropertyPreviewLabel::draw(QImage& image)
         pt.setX( (i-size2) / (size2-1) );
         pt.setY( (j-size2) / (size2-1) );
         pt.setZ( sqrt(qMax(1. - pt.x()*pt.x() - pt.y()*pt.y(), 0.)) );
-        
+
         QVector3D normal = pt;
         normal.normalize();
 
@@ -287,7 +287,7 @@ void ctkMaterialPropertyPreviewLabel::draw(QImage& image)
         view.setY(-pt.y());
         view.setZ(5 - pt.z());
         view.normalize();
-        
+
         qreal dot = QVector3D::dotProduct(normal, light);
         QVector3D ref;
         ref.setX( 2.*normal.x()*dot - light.x());
@@ -296,16 +296,16 @@ void ctkMaterialPropertyPreviewLabel::draw(QImage& image)
         ref.normalize();
 
         qreal diffuseComp = qMax(diffuse * dot, 0.);
-        
-        qreal specularDot = qMax(QVector3D::dotProduct(ref, view), 0.);
-        
+
+        qreal specularDot = qMax(QVector3D::dotProduct(ref, view), static_cast<float>(0));
+
         qreal specularComp = specular*pow(specularDot, specular_power);
-        
+
         QVector3D intensity;
         intensity.setX( qMin((ambient + diffuseComp)*d->Color.redF() + specularComp, static_cast<qreal>(1.)));
         intensity.setY( qMin((ambient + diffuseComp)*d->Color.greenF() + specularComp, static_cast<qreal>(1.)));
         intensity.setZ( qMin((ambient + diffuseComp)*d->Color.blueF() + specularComp, static_cast<qreal>(1.)));
-        
+
         if (opacity == 1.)
           {
           rgba = qRgba(static_cast<unsigned char>(255. * intensity.x() * opacity),

+ 0 - 1
Libs/Widgets/ctkMenuButton.cpp

@@ -20,7 +20,6 @@
 
 // Qt includes
 #include <QApplication>
-#include <QCleanlooksStyle>
 #include <QDebug>
 #include <QDesktopWidget>
 #include <QLayout>

+ 1 - 0
Libs/Widgets/ctkMenuComboBox.cpp

@@ -19,6 +19,7 @@
 =========================================================================*/
 
 // Qt includes
+#include <QAbstractItemView>
 #include <QActionEvent>
 #include <QCompleter>
 #include <QDebug>

+ 3 - 3
Libs/Widgets/ctkMenuComboBox_p.h

@@ -23,7 +23,7 @@
 
 // Qt includes
 #include <QComboBox>
-#include <QWeakPointer>
+#include <QPointer>
 
 // CTK includes
 #include "ctkMenuComboBox.h"
@@ -46,7 +46,7 @@ public:
 Q_SIGNALS:
   void popupShown();
 public:
-  QWeakPointer<QMenu>  Menu;
+  QPointer<QMenu>  Menu;
 };
 
 // -------------------------------------------------------------------------
@@ -86,7 +86,7 @@ protected:
 
   ctkMenuComboBoxInternal*    MenuComboBox;
   ctkCompleter*               SearchCompleter;
-  QWeakPointer<QMenu>         Menu;
+  QPointer<QMenu>             Menu;
   QToolButton*                SearchButton;
 };
 

+ 22 - 3
Libs/Widgets/ctkPixmapIconEngine.cpp

@@ -33,7 +33,12 @@ ctkPixmapIconEngine::ctkPixmapIconEngine()
 }
 
 ctkPixmapIconEngine::ctkPixmapIconEngine(const ctkPixmapIconEngine &other)
-    : QIconEngineV2(other), pixmaps(other.pixmaps)
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  : QIconEngine(other)
+#else
+  : QIconEngineV2(other)
+#endif
+  , pixmaps(other.pixmaps)
 {
 }
 
@@ -271,7 +276,11 @@ QString ctkPixmapIconEngine::key() const
     return QLatin1String("ctkPixmapIconEngine");
 }
 
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+QIconEngine *ctkPixmapIconEngine::clone() const
+#else
 QIconEngineV2 *ctkPixmapIconEngine::clone() const
+#endif
 {
     return new ctkPixmapIconEngine(*this);
 }
@@ -326,10 +335,16 @@ bool ctkPixmapIconEngine::write(QDataStream &out) const
 
 void ctkPixmapIconEngine::virtual_hook(int id, void *data)
 {
-    switch (id) {
+  switch (id) {
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+    case QIconEngine::AvailableSizesHook: {
+        QIconEngine::AvailableSizesArgument &arg =
+            *reinterpret_cast<QIconEngine::AvailableSizesArgument*>(data);
+#else
     case QIconEngineV2::AvailableSizesHook: {
         QIconEngineV2::AvailableSizesArgument &arg =
             *reinterpret_cast<QIconEngineV2::AvailableSizesArgument*>(data);
+#endif
         arg.sizes.clear();
         for (int i = 0; i < pixmaps.size(); ++i) {
             ctkPixmapIconEngineEntry &pe = pixmaps[i];
@@ -343,6 +358,10 @@ void ctkPixmapIconEngine::virtual_hook(int id, void *data)
         break;
     }
     default:
-        QIconEngineV2::virtual_hook(id, data);
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+      QIconEngine::virtual_hook(id, data);
+#else
+      QIconEngineV2::virtual_hook(id, data);
+#endif
     }
 }

+ 11 - 1
Libs/Widgets/ctkPixmapIconEngine.h

@@ -45,7 +45,13 @@ struct ctkPixmapIconEngineEntry
 };
 
 /// \ingroup Widgets
-class CTK_WIDGETS_EXPORT ctkPixmapIconEngine : public QIconEngineV2 {
+class CTK_WIDGETS_EXPORT ctkPixmapIconEngine
+#if QT_VERSION >= 0x50000
+  : public QIconEngine
+#else
+  : public QIconEngineV2
+#endif
+{
 public:
     ctkPixmapIconEngine();
     ctkPixmapIconEngine(const ctkPixmapIconEngine &);
@@ -59,7 +65,11 @@ public:
 
     // v2 functions
     QString key() const;
+#if QT_VERSION >= 0x50000
+    QIconEngine *clone() const;
+#else
     QIconEngineV2 *clone() const;
+#endif
     bool read(QDataStream &in);
     bool write(QDataStream &out) const;
     void virtual_hook(int id, void *data);

+ 13 - 8
Libs/Widgets/ctkPopupWidget.cpp

@@ -80,6 +80,10 @@ bool ctkPopupWidgetPrivate::eventFilter(QObject* obj, QEvent* event)
 {
   Q_Q(ctkPopupWidget);
   QWidget* widget = qobject_cast<QWidget*>(obj);
+  if (!widget)
+    {
+    return this->Superclass::eventFilter(obj, event);
+    }
   // Here are the application events, it's a lot of events, so we need to be
   // careful to be fast.
   if (event->type() == QEvent::ApplicationDeactivate)
@@ -91,7 +95,7 @@ bool ctkPopupWidgetPrivate::eventFilter(QObject* obj, QEvent* event)
     {
     QTimer::singleShot(0, this, SLOT(updateVisibility()));
     }
-  if (!this->BaseWidget)
+  if (this->BaseWidget.isNull())
     {
     return false;
     }
@@ -176,7 +180,7 @@ void ctkPopupWidgetPrivate::updateVisibility()
   Q_Q(ctkPopupWidget);
   // If the BaseWidget window is active, then there is no reason to cover the
   // popup.
-  if (!this->BaseWidget  ||
+  if (this->BaseWidget.isNull()  ||
       // the popupwidget active window is not active
       (!this->BaseWidget->window()->isActiveWindow() &&
       // and no other active window
@@ -209,7 +213,7 @@ void ctkPopupWidgetPrivate::updateVisibility()
     }
   // If the base widget is hidden or minimized, we don't want to restore the
   // popup.
-  if (this->BaseWidget &&
+  if (!this->BaseWidget.isNull() &&
       (!this->BaseWidget->isVisible() ||
         this->BaseWidget->window()->windowState() & Qt::WindowMinimized))
     {
@@ -237,6 +241,7 @@ void ctkPopupWidgetPrivate::temporarilyHiddenOn()
 void ctkPopupWidgetPrivate::temporarilyHiddenOff()
 {
   Q_Q(ctkPopupWidget);
+
   int forcedClosed = this->property("forcedClosed").toInt();
   if (forcedClosed > 0)
     {
@@ -287,7 +292,7 @@ void ctkPopupWidget::setActive(bool active)
   d->Active = active;
   if (d->Active)
     {
-    if (d->BaseWidget)
+    if (!d->BaseWidget.isNull())
       {
       d->BaseWidget->installEventFilter(this);
       }
@@ -299,7 +304,7 @@ void ctkPopupWidget::setActive(bool active)
     }
   else // not active
     {
-    if (d->BaseWidget)
+    if (!d->BaseWidget.isNull())
       {
       d->BaseWidget->removeEventFilter(this);
       }
@@ -315,12 +320,12 @@ void ctkPopupWidget::setActive(bool active)
 void ctkPopupWidget::setBaseWidget(QWidget* widget)
 {
   Q_D(ctkPopupWidget);
-  if (d->BaseWidget)
+  if (!d->BaseWidget.isNull())
     {
     d->BaseWidget->removeEventFilter(this);
     }
   this->Superclass::setBaseWidget(widget);
-  if (d->BaseWidget && d->Active)
+  if (!d->BaseWidget.isNull() && d->Active)
     {
     d->BaseWidget->installEventFilter(this);
     }
@@ -516,7 +521,7 @@ void ctkPopupWidget::updatePopup()
      // to be automatically open, the mouse has to be over a child widget
       mouseOver &&
      // disable opening the popup when the popup is disabled
-      (!d->BaseWidget || d->BaseWidget->isEnabled()))
+      (d->BaseWidget.isNull() || d->BaseWidget->isEnabled()))
     {
     this->showPopup();
     }

+ 2 - 2
Libs/Widgets/ctkRangeWidget.cpp

@@ -21,7 +21,7 @@
 // Qt includes
 #include <QDebug>
 #include <QMouseEvent>
-#include <QWeakPointer>
+#include <QPointer>
 
 // CTK includes
 #include "ctkRangeWidget.h"
@@ -56,7 +56,7 @@ public:
   double        MaximumValueBeforeChange;
   bool          AutoSpinBoxWidth;
   Qt::Alignment SpinBoxAlignment;
-  QWeakPointer<ctkValueProxy> Proxy;
+  QPointer<ctkValueProxy> Proxy;
 };
 
 // --------------------------------------------------------------------------

+ 2 - 1
Libs/Widgets/ctkScreenshotDialog_p.h

@@ -22,6 +22,7 @@
 #define __ctkScreenshotDialog_p_h
 
 // Qt includes
+#include <QPointer>
 #include <QTimer>
 
 // CTK includes
@@ -72,7 +73,7 @@ public Q_SLOTS:
   void onHeightEdited();
 
 public:
-  QWeakPointer<QWidget> WidgetToGrab;
+  QPointer<QWidget>     WidgetToGrab;
   QPushButton*          CaptureButton;
   int                   CountDownValue;
   QTimer                CountDownTimer;

+ 0 - 0
Libs/Widgets/ctkSliderWidget.cpp


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.