From 302981ebdc77a488e9d49c8887cd83ce133cd66f Mon Sep 17 00:00:00 2001 From: Mike Walters Date: Sun, 30 Nov 2025 23:41:36 +0000 Subject: [PATCH] Support Qt6 --- src/CMakeLists.txt | 24 +++++++++++++++++------- src/plotview.cpp | 8 ++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 05b20e7..8bc0bc2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,8 +52,10 @@ list(APPEND inspectrum_sources util.cpp ) -find_package(Qt5Widgets REQUIRED) -find_package(Qt5Concurrent REQUIRED) +find_package(Qt6 COMPONENTS Core Concurrent Widgets) +if (NOT Qt6_FOUND) + find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets) +endif() find_package(FFTW REQUIRED) find_package(Liquid REQUIRED) @@ -64,11 +66,19 @@ include_directories( add_executable(inspectrum ${EXE_ARGS} ${inspectrum_sources}) -target_link_libraries(inspectrum - Qt5::Core Qt5::Widgets Qt5::Concurrent - ${FFTW_LIBRARIES} - ${LIQUID_LIBRARIES} -) +if (Qt6_FOUND) + target_link_libraries(inspectrum + Qt6::Core Qt6::Widgets Qt6::Concurrent + ${FFTW_LIBRARIES} + ${LIQUID_LIBRARIES} + ) +else() + target_link_libraries(inspectrum + Qt5::Core Qt5::Widgets Qt5::Concurrent + ${FFTW_LIBRARIES} + ${LIQUID_LIBRARIES} + ) +endif() set(INSTALL_DEFAULT_BINDIR "bin" CACHE STRING "Appended to CMAKE_INSTALL_PREFIX") diff --git a/src/plotview.cpp b/src/plotview.cpp index 100055b..798d2ab 100644 --- a/src/plotview.cpp +++ b/src/plotview.cpp @@ -91,7 +91,11 @@ void PlotView::updateAnnotationTooltip(QMouseEvent *event) } else { QString* comment = spectrogramPlot->mouseAnnotationComment(event); if (comment != nullptr) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QToolTip::showText(event->globalPosition().toPoint(), *comment); +#else QToolTip::showText(event->globalPos(), *comment); +#endif } else { QToolTip::hideText(); } @@ -261,7 +265,11 @@ bool PlotView::viewportEvent(QEvent *event) { for (auto&& plot : plots) { auto mouse_event = QMouseEvent( event->type(), +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QPoint(mouseEvent->position().x(), mouseEvent->position().y() - plotY), +#else + QPoint(mouseEvent->pos().x(), mouseEvent->pos().y() - plotY), +#endif mouseEvent->button(), mouseEvent->buttons(), QApplication::keyboardModifiers()