- 将需要调用的函数所在类设为QML的根节点即可实现在QML中调用C++函数
#include
#include
#include “notificationclient.h”
int main(int argc, char **argv){
QGuiApplication app(argc, argv);
QQuickView view;
NotificationClient *notificationClient = new NotificationClient(&view);
view.engine()->rootContext()->setContextProperty(QLatin1String(“notificationClient”), notificationClient); view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl(QStringLiteral(“qrc:/qml/main.qml”))); view.show();
return app.exec();
}



