Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Trigger custom QML Event from c++

$
0
0
Hey there, maybe it is a really dumb question but i am a bit confused about how signals and slots between c++ and qml work. I like to trigger a Custom event in my QML like following: Text {          text: applicationData.getCurrentDateTime22()            Connections {              target: applicationData              onImageChanged: console.log("The application data changed!")          }      } But i am not sure how to trigger “onImageChanged”. here is some more code: class ApplicationData : public QObject {     Q_OBJECT public:     Q_INVOKABLE QString getCurrentDateTime22(){         QString out;         out = "return value";         return out;     } public slots:     //void imageChanged2();   signals:      void imageChanged(); }; int main(int argc, char *argv[]) {     QApplication app(argc, argv);       QQmlApplicationEngine engine;       ApplicationData data;     engine.rootContext()->setContextProperty("applicationData", &data);         engine.load(QUrl(QStringLiteral("qrc:///main.qml")));       return app.exec(); }

Viewing all articles
Browse latest Browse all 4972

Latest Images

Trending Articles



Latest Images