Hello QGC developers,
I am trying to create a new window in AnalyzeTools option, along with MavlinkInspector , vibration and everything. I have written C++ backend with Q_INVOKABLE functions and also window QML .
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Window 2.2
import QtCharts 2.3
import QGroundControl 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.ScreenTools 1.0
AnalyzePage {
id: CustomPage
headerComponent: headerComponent
pageComponent: pageComponent
pageDescription: qsTr(" Application User Interface.")
allowPopout: true
property int curCompID: 0
property real maxButtonWidth: 0
property real _margin: ScreenTools.defaultFontPixelWidth
property real _butttonWidth: ScreenTools.defaultFontPixelWidth * 30
RowLayout {
width: availableWidth
height: availableHeight
Connections {
target: CustomController
}
Column {
spacing: _margin
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
QGCButton{
// enabled:
text: qsTr("Launch App")
width: _butttonWidth
onClicked: {
CustomController.launch()
}
}
QGCButton{
// enabled:
text: qsTr("Stop App")
width: _butttonWidth
onClicked: {
CustomController.stop()
}
}
}
}
}
}
C++ Code. CustomController.h
// Controller for CustomPage.qml
class CustomController : public QObject{
Q_OBJECT
public:
CustomController(void);
Q_INVOKABLE void launch ();
Q_INVOKABLE void stop ();
signals:
// private slots:
private:
bool _launched;
Vehicle* _vehicle;
UASInterface* _uas;
QTimer _timer;
void _sendLauncherMessage (uint8_t launch , uint8_t msg_type , uint8_t error_type);
};
In cpp file there are definitions for launch and stop functions mentioned above.
I have modified the CMakeLists.txt and also QGCApplication.cc to add
qmlRegisterType<CustomController> (kQGCControllers, 1 ,0, "CustomController");
This is throwing a error
TypeError: Property 'launch' of object [object Object] is not a function.
Any possible reason why C++ functions are not exposed to QML here ?
I am very new to QT QML development . Any help would be appreciated .Thanks.