Register MAVSDK::Telemetry::Position type for Qt

Without this application can't get position events in Qt5 based systems.

Type: Improvement
This commit is contained in:
Tuomas Järvinen
2024-05-20 18:11:06 +02:00
parent 028737478b
commit dda897a573
2 changed files with 4 additions and 2 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
QT = core QT = core
CONFIG += c++17 cmdline CONFIG += cmdline
# Reduce compiler warnings from the ArduPilot headers # Reduce compiler warnings from the ArduPilot headers
QMAKE_CXXFLAGS += -Wno-address-of-packed-member QMAKE_CXXFLAGS += -Wno-address-of-packed-member -std=gnu++1z
# MAVSDK pkg-config file is garbage. Add dependency manually # MAVSDK pkg-config file is garbage. Add dependency manually
QMAKE_RPATHDIR += /usr/local/lib QMAKE_RPATHDIR += /usr/local/lib
+2
View File
@@ -1,5 +1,6 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QDebug> #include <QDebug>
#include <QMetaProperty>
#include <QThread> #include <QThread>
#include <QTimer> #include <QTimer>
@@ -74,6 +75,7 @@ bool AzDroneController::stateTelemetryModule(void)
// Subscripe to position updates. Updated comes from different MAVSDK thread. Send position // Subscripe to position updates. Updated comes from different MAVSDK thread. Send position
// as signal to this class (Qt::QueuedConnection) so that it's handled in the main thread. // as signal to this class (Qt::QueuedConnection) so that it's handled in the main thread.
qRegisterMetaType<Telemetry::Position>("Telemetry::Position");
connect(this, &AzDroneController::newPosition, this, &AzDroneController::newPositionSlot, Qt::QueuedConnection); connect(this, &AzDroneController::newPosition, this, &AzDroneController::newPositionSlot, Qt::QueuedConnection);
mTelemetry->subscribe_position([this](Telemetry::Position position) { emit newPosition(position); }); mTelemetry->subscribe_position([this](Telemetry::Position position) { emit newPosition(position); });