#ifndef SHAREDATA_H #define SHAREDATA_H #include "serialcontroller.h" #include #include class ShareData : public QObject { Q_OBJECT Q_PROPERTY(QString _txt READ rtxt WRITE settxt NOTIFY txtchanged) public: explicit ShareData(QObject *parent = nullptr); QString rtxt() const{ return _txt; } void settxt(QString s){ _txt = s; emit txtchanged(); } Q_INVOKABLE void getValFromQml(int v) { qDebug() << "value from qml is :" << v; emit valueFromCpp(456); } Q_INVOKABLE int OpenUart(QString port,QString baudRate,QString dataBits,QString stopBits, QString flow); Q_INVOKABLE int CloseSerial(); QString _txt = "hello world\r\n"; signals: void txtchanged(); void valueFromCpp(int val); private: SerialController *mSerialController; }; #endif // SHAREDATA_H