diff --git a/CMakeLists.txt b/CMakeLists.txt index f7e948954..93549c943 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -594,12 +594,15 @@ endif() status("") status(" GUI: ") -if(HAVE_QT) +if(HAVE_QT5) + status(" QT 5.x:" HAVE_QT THEN "YES (ver ${Qt5Core_VERSION_STRING})" ELSE NO) + status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${Qt5OpenGL_LIBRARIES} ${Qt5OpenGL_VERSION_STRING})" ELSE NO) +elseif(HAVE_QT) status(" QT 4.x:" HAVE_QT THEN "YES (ver ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} ${QT_EDITION})" ELSE NO) status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO) else() if(DEFINED WITH_QT) - status(" QT 4.x:" NO) + status(" QT:" NO) endif() if(DEFINED WITH_WIN32UI) status(" Win32 UI:" HAVE_WIN32UI THEN YES ELSE NO) diff --git a/cmake/OpenCVFindLibsGUI.cmake b/cmake/OpenCVFindLibsGUI.cmake index 3b42f1b0b..2ea864c16 100644 --- a/cmake/OpenCVFindLibsGUI.cmake +++ b/cmake/OpenCVFindLibsGUI.cmake @@ -13,12 +13,31 @@ if(WITH_WIN32UI) endif(WITH_WIN32UI) # --- QT4 --- -ocv_clear_vars(HAVE_QT) +ocv_clear_vars(HAVE_QT HAVE_QT5) if(WITH_QT) - find_package(Qt4) - if(QT4_FOUND) - set(HAVE_QT TRUE) - add_definitions(-DHAVE_QT) # We need to define the macro this way, using cvconfig.h does not work + if(NOT CMAKE_VERSION VERSION_LESS 2.8.3 AND NOT WITH_QT EQUAL 4) + find_package(Qt5Core) + find_package(Qt5Gui) + find_package(Qt5Widgets) + find_package(Qt5Test) + find_package(Qt5Concurrent) + if(Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND AND Qt5Concurrent_FOUND) + set(HAVE_QT5 ON) + set(HAVE_QT ON) + add_definitions(-DHAVE_QT) + find_package(Qt5OpenGL) + if(Qt5OpenGL_FOUND) + set(QT_QTOPENGL_FOUND ON) + endif() + endif() + endif() + + if(NOT HAVE_QT) + find_package(Qt4) + if(QT4_FOUND) + set(HAVE_QT TRUE) + add_definitions(-DHAVE_QT) # We need to define the macro this way, using cvconfig.h does not work + endif() endif() endif() diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 3eec81d11..4c60867af 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -70,7 +70,26 @@ set(highgui_srcs file(GLOB highgui_ext_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h") -if(HAVE_QT) +if(HAVE_QT5) + set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + + QT5_ADD_RESOURCES(_RCC_OUTFILES src/window_QT.qrc) + list(APPEND highgui_srcs src/window_QT.cpp src/window_QT.h ${_RCC_OUTFILES}) + + foreach(dt5_dep Core Gui Widgets Test Concurrent) + add_definitions(${Qt5${dt5_dep}_DEFINITIONS}) + include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS}) + list(APPEND HIGHGUI_LIBRARIES ${Qt5${dt5_dep}_LIBRARIES}) + endforeach() + + if(HAVE_QT_OPENGL) + add_definitions(${Qt5OpenGL_DEFINITIONS}) + include_directories(${Qt5OpenGL_INCLUDE_DIRS}) + list(APPEND HIGHGUI_LIBRARIES ${Qt5OpenGL_LIBRARIES}) + endif() + +elseif(HAVE_QT) if (HAVE_QT_OPENGL) set(QT_USE_QTOPENGL TRUE) endif() diff --git a/modules/highgui/src/window_QT.h b/modules/highgui/src/window_QT.h index 1b07442dc..089997f51 100644 --- a/modules/highgui/src/window_QT.h +++ b/modules/highgui/src/window_QT.h @@ -48,13 +48,13 @@ #endif #include -#include +#include #include #include -#include +#include #include #include -#include +#include #include #include #include @@ -78,7 +78,7 @@ #include #include #include -#include +#include //start private enum enum { CV_MODE_NORMAL = 0, CV_MODE_OPENGL = 1 };