Skip to content

Commit 302981e

Browse files
committed
Support Qt6
1 parent 531402f commit 302981e

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

src/CMakeLists.txt

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ list(APPEND inspectrum_sources
5252
util.cpp
5353
)
5454

55-
find_package(Qt5Widgets REQUIRED)
56-
find_package(Qt5Concurrent REQUIRED)
55+
find_package(Qt6 COMPONENTS Core Concurrent Widgets)
56+
if (NOT Qt6_FOUND)
57+
find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets)
58+
endif()
5759
find_package(FFTW REQUIRED)
5860
find_package(Liquid REQUIRED)
5961

@@ -64,11 +66,19 @@ include_directories(
6466

6567
add_executable(inspectrum ${EXE_ARGS} ${inspectrum_sources})
6668

67-
target_link_libraries(inspectrum
68-
Qt5::Core Qt5::Widgets Qt5::Concurrent
69-
${FFTW_LIBRARIES}
70-
${LIQUID_LIBRARIES}
71-
)
69+
if (Qt6_FOUND)
70+
target_link_libraries(inspectrum
71+
Qt6::Core Qt6::Widgets Qt6::Concurrent
72+
${FFTW_LIBRARIES}
73+
${LIQUID_LIBRARIES}
74+
)
75+
else()
76+
target_link_libraries(inspectrum
77+
Qt5::Core Qt5::Widgets Qt5::Concurrent
78+
${FFTW_LIBRARIES}
79+
${LIQUID_LIBRARIES}
80+
)
81+
endif()
7282

7383
set(INSTALL_DEFAULT_BINDIR "bin" CACHE STRING "Appended to CMAKE_INSTALL_PREFIX")
7484

src/plotview.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ void PlotView::updateAnnotationTooltip(QMouseEvent *event)
9191
} else {
9292
QString* comment = spectrogramPlot->mouseAnnotationComment(event);
9393
if (comment != nullptr) {
94+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
95+
QToolTip::showText(event->globalPosition().toPoint(), *comment);
96+
#else
9497
QToolTip::showText(event->globalPos(), *comment);
98+
#endif
9599
} else {
96100
QToolTip::hideText();
97101
}
@@ -261,7 +265,11 @@ bool PlotView::viewportEvent(QEvent *event) {
261265
for (auto&& plot : plots) {
262266
auto mouse_event = QMouseEvent(
263267
event->type(),
268+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
264269
QPoint(mouseEvent->position().x(), mouseEvent->position().y() - plotY),
270+
#else
271+
QPoint(mouseEvent->pos().x(), mouseEvent->pos().y() - plotY),
272+
#endif
265273
mouseEvent->button(),
266274
mouseEvent->buttons(),
267275
QApplication::keyboardModifiers()

0 commit comments

Comments
 (0)