Skip to content

Commit

Permalink
Enable Support for QT6
Browse files Browse the repository at this point in the history
In the CMakeLists.txt add a branch to check of qt6 is available.
If it is, use that, otherwise assume QT5.

In qfsignalproxy slightly adapt call to constructor of QVariant.
QVariant(type, void*) signature has changed between QT5 and QT6.

in qfstore adapt call to constructor of QQmlListProperty.
Signature has changed between QT5.13 and QT6
  • Loading branch information
CasparKielwein committed Aug 27, 2021
1 parent 2a37acf commit 8fd171a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ endif()
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")

include(GNUInstallDirs)
find_package(Qt5 COMPONENTS Core Quick Qml Gui CONFIG REQUIRED)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core CONFIG REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick Qml Gui CONFIG REQUIRED)

set(quickflux_PRIVATE_SOURCES
${SRC_DIR}/priv/qfhook.cpp
Expand Down Expand Up @@ -99,9 +100,9 @@ add_library(QuickFlux::quickflux ALIAS quickflux)

target_link_libraries(quickflux
PUBLIC
Qt5::Qml
Qt5::Quick
Qt5::Core
Qt${QT_VERSION_MAJOR}::Qml
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Core
)

target_include_directories(quickflux
Expand Down
4 changes: 4 additions & 0 deletions src/priv/qfsignalproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ int QFSignalProxy::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (type == QMetaType::QVariant) {
v = *reinterpret_cast<QVariant *>(_a[i + 1]);
} else {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
v = QVariant(QMetaType{type}, _a[i + 1]);
#else
v = QVariant(type, _a[i + 1]);
#endif
}

message[parameterNames.at(i)] = v;
Expand Down
8 changes: 8 additions & 0 deletions src/qfstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ QFStore::QFStore(QObject *parent) : QObject(parent) , m_filterFunctionEnabled(fa

QQmlListProperty<QObject> QFStore::children()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return QQmlListProperty<QObject>(qobject_cast<QObject*>(this), &m_children);
#else
return QQmlListProperty<QObject>(qobject_cast<QObject*>(this), m_children);
#endif
}

void QFStore::dispatch(QString type, QJSValue message)
Expand Down Expand Up @@ -245,7 +249,11 @@ void QFStore::setup()

QQmlListProperty<QObject> QFStore::redispatchTargets()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return QQmlListProperty<QObject>(qobject_cast<QObject*>(this), &m_redispatchTargets);
#else
return QQmlListProperty<QObject>(qobject_cast<QObject*>(this), m_redispatchTargets);
#endif
}


Expand Down

0 comments on commit 8fd171a

Please sign in to comment.