Export watcher:
int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); QFileSystemWatcher watcher; watcher.addPath("data.json"); readJSON myGlobal; engine.rootContext()->setContextProperty("myGlobalObject", &myGlobal); engine.rootContext()->setContextProperty("watcher", &watcher); engine.load(url); return app.exec(); }and use Connections:
Window { visible: true width: 800 height: 800 title: qsTr("Screen Display") DisplaysForm { function callCPP(text) { var dataOne = myGlobalObject.readingJson(text) dataOne = parseFloat(dataOne) return dataOne } function updateDisplay() { var value = callCPP("Engine_Spd") engSpd_txt.text = value var value1 = callCPP("Engine_Power") engPwr_txt.text = value1 } Connections{ target: watcher function onFileChanged(path){ console.log(path) updateDisplay() } } }