From ff85dcbaa9a8e2464812f481c329e483d0454402 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <tom@trondeau.com>
Date: Thu, 28 Apr 2016 10:53:12 -0400
Subject: qtgui: Fixes for edit_box_msg to work with QT5.

---
 gr-qtgui/examples/c++/CMakeLists.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'gr-qtgui/examples/c++')

diff --git a/gr-qtgui/examples/c++/CMakeLists.txt b/gr-qtgui/examples/c++/CMakeLists.txt
index ad84287367..796c292b81 100644
--- a/gr-qtgui/examples/c++/CMakeLists.txt
+++ b/gr-qtgui/examples/c++/CMakeLists.txt
@@ -24,7 +24,7 @@ include_directories(
 	${GR_BLOCKS_INCLUDE_DIRS}
 	${GR_FFT_INCLUDE_DIRS}
 	${GNURADIO_RUNTIME_INCLUDE_DIRS}
-        ${QT_INCLUDE_DIRS}
+        ${Qt5Widgets_INCLUDE_DIRS}
         ${Boost_INCLUDE_DIRS}
 )
 
@@ -36,9 +36,10 @@ list(APPEND QTGUI_LIBRARIES
   gnuradio-fft
   gnuradio-runtime
   ${QWT_LIBRARY_DIRS}
+  ${Qt5Widgets_LIBRARIES}
 )
 
-QT4_WRAP_CPP(qtgui_moc_sources display_qt.h)
+QT5_WRAP_CPP(qtgui_moc_sources display_qt.h)
 add_executable(display_qt display_qt.cc ${qtgui_moc_sources})
 target_link_libraries(display_qt ${QTGUI_LIBRARIES})
 
-- 
cgit v1.2.3


From 22778fbd1b1a89188793b7f4c07dbe2d97a6ec67 Mon Sep 17 00:00:00 2001
From: Paul Cercueil <paul.cercueil@analog.com>
Date: Mon, 20 Jun 2016 18:37:43 +0200
Subject: gr-qtgui: Allow build with Qt4 or Qt5 (default)

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
---
 gr-qtgui/CMakeLists.txt                      | 27 ++++++++++++++++++++-------
 gr-qtgui/examples/c++/CMakeLists.txt         | 11 ++++++++---
 gr-qtgui/include/gnuradio/qtgui/form_menus.h |  4 ++++
 gr-qtgui/lib/CMakeLists.txt                  | 14 ++++++++++----
 4 files changed, 42 insertions(+), 14 deletions(-)

(limited to 'gr-qtgui/examples/c++')

diff --git a/gr-qtgui/CMakeLists.txt b/gr-qtgui/CMakeLists.txt
index e3dcf7b86b..c06e516917 100644
--- a/gr-qtgui/CMakeLists.txt
+++ b/gr-qtgui/CMakeLists.txt
@@ -22,14 +22,27 @@
 ########################################################################
 include(GrBoost)
 
-find_package(Qt5Widgets)
-
-find_package(Qwt)
-
 find_package(PythonLibs 2)
 
 include(GrPython)
-GR_PYTHON_CHECK_MODULE("PyQt5" PyQt5 True PYQT5_FOUND)
+
+set(DESIRED_QT_VERSION 5 CACHE STRING "The Qt version to use (4 or 5)")
+set_property(CACHE DESIRED_QT_VERSION PROPERTY STRINGS 4 5)
+
+if (DESIRED_QT_VERSION MATCHES 4)
+    find_package(Qt4 COMPONENTS QtCore QtGui)
+    set(QT_FOUND ${Qt4_FOUND})
+    include(GrSetupQt4)
+else()
+    find_package(Qt5Widgets)
+    set(QT_FOUND ${Qt5Widgets_FOUND})
+    set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES})
+    set(QT_INCLUDE_DIRS ${Qt5Widgets_INCLUDE_DIRS})
+endif()
+
+GR_PYTHON_CHECK_MODULE("PyQt${DESIRED_QT_VERSION}" PyQt${DESIRED_QT_VERSION} True PYQT${DESIRED_QT_VERSION}_FOUND)
+
+find_package(Qwt)
 
 ########################################################################
 # Register component
@@ -37,13 +50,13 @@ GR_PYTHON_CHECK_MODULE("PyQt5" PyQt5 True PYQT5_FOUND)
 include(GrComponent)
 if(NOT CMAKE_CROSSCOMPILING)
     set(qt_gui_python_deps
-        PYQT5_FOUND
+        PYQT${DESIRED_QT_VERSION}_FOUND
     )
 endif(NOT CMAKE_CROSSCOMPILING)
 
 GR_REGISTER_COMPONENT("gr-qtgui" ENABLE_GR_QTGUI
     Boost_FOUND
-    Qt5Widgets_FOUND
+    QT_FOUND
     QWT_FOUND
     ENABLE_VOLK
     ENABLE_GNURADIO_RUNTIME
diff --git a/gr-qtgui/examples/c++/CMakeLists.txt b/gr-qtgui/examples/c++/CMakeLists.txt
index 796c292b81..89b4baef71 100644
--- a/gr-qtgui/examples/c++/CMakeLists.txt
+++ b/gr-qtgui/examples/c++/CMakeLists.txt
@@ -24,7 +24,7 @@ include_directories(
 	${GR_BLOCKS_INCLUDE_DIRS}
 	${GR_FFT_INCLUDE_DIRS}
 	${GNURADIO_RUNTIME_INCLUDE_DIRS}
-        ${Qt5Widgets_INCLUDE_DIRS}
+        ${QT_INCLUDE_DIRS}
         ${Boost_INCLUDE_DIRS}
 )
 
@@ -36,10 +36,15 @@ list(APPEND QTGUI_LIBRARIES
   gnuradio-fft
   gnuradio-runtime
   ${QWT_LIBRARY_DIRS}
-  ${Qt5Widgets_LIBRARIES}
+  ${QT_LIBRARIES}
 )
 
-QT5_WRAP_CPP(qtgui_moc_sources display_qt.h)
+if (${DESIRED_QT_VERSION} MATCHES 4)
+    QT4_WRAP_CPP(qtgui_moc_sources display_qt.h)
+else()
+    QT5_WRAP_CPP(qtgui_moc_sources display_qt.h)
+endif()
+
 add_executable(display_qt display_qt.cc ${qtgui_moc_sources})
 target_link_libraries(display_qt ${QTGUI_LIBRARIES})
 
diff --git a/gr-qtgui/include/gnuradio/qtgui/form_menus.h b/gr-qtgui/include/gnuradio/qtgui/form_menus.h
index f2a0cb052f..1fa7413117 100644
--- a/gr-qtgui/include/gnuradio/qtgui/form_menus.h
+++ b/gr-qtgui/include/gnuradio/qtgui/form_menus.h
@@ -28,7 +28,11 @@
 #include <QtGui/QtGui>
 #include <QtGui/QIntValidator>
 #include <QtGui/QDoubleValidator>
+
+#if QT_VERSION >= 0x050000
 #include <QtWidgets/QtWidgets>
+#endif
+
 #include <qwt_symbol.h>
 #include <gnuradio/filter/firdes.h>
 #include <gnuradio/qtgui/qtgui_types.h>
diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt
index 4827ec4f3f..a5e63b232e 100644
--- a/gr-qtgui/lib/CMakeLists.txt
+++ b/gr-qtgui/lib/CMakeLists.txt
@@ -45,8 +45,14 @@ set(qtgui_moc_hdrs
     ${qtgui_mod_includedir}/VectorDisplayPlot.h
     edit_box_msg_impl.h
 )
-QT5_WRAP_CPP(qtgui_moc_sources ${qtgui_moc_hdrs})
-QT5_WRAP_UI(qtgui_ui_hdrs spectrumdisplayform.ui)
+
+if (${DESIRED_QT_VERSION} MATCHES 4)
+    QT4_WRAP_CPP(qtgui_moc_sources ${qtgui_moc_hdrs})
+    QT4_WRAP_UI(qtgui_ui_hdrs spectrumdisplayform.ui)
+else()
+    QT5_WRAP_CPP(qtgui_moc_sources ${qtgui_moc_hdrs})
+    QT5_WRAP_UI(qtgui_ui_hdrs spectrumdisplayform.ui)
+endif()
 
 #FIXME the sources expect <foo>.ui.h, but the macros generate ui_foo.h
 #avoid changing the sources by generating the header with the include
@@ -127,7 +133,7 @@ include_directories(
     ${GNURADIO_RUNTIME_INCLUDE_DIRS}
     ${VOLK_INCLUDE_DIRS}
     ${QWT_INCLUDE_DIRS}
-    ${Qt5Widgets_INCLUDE_DIRS}
+    ${QT_INCLUDE_DIRS}
     ${FFTW3F_INCLUDE_DIRS}
     ${LOG4CPP_INCLUDE_DIRS}
     ${Boost_INCLUDE_DIRS}
@@ -156,7 +162,7 @@ list(APPEND qtgui_libs
     gnuradio-filter
     ${VOLK_LIBRARIES}
     ${QWT_LIBRARIES}
-    ${Qt5Widgets_LIBRARIES}
+    ${QT_LIBRARIES}
     ${FFTW3F_LIBRARIES}
     ${LOG4CPP_LIBRARIES}
 )
-- 
cgit v1.2.3