Support Qt6

This commit is contained in:
Mike Walters
2025-11-30 23:41:36 +00:00
parent 531402f4e9
commit 302981ebdc
2 changed files with 25 additions and 7 deletions

View File

@@ -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")

View File

@@ -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()