engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QObject *pMsgBox = engine.rootObjects().first()->findChild<QObject*>("msgBox");
if(pMsgBox != Q_NULLPTR){
QVariant qmlFuncRet;
bool ret = QMetaObject::invokeMethod(pMsgBox, "showMsg", Qt::AutoConnection,
Q_RETURN_ARG(QVariant, qmlFuncRet),
Q_ARG(QVariant, string));
}
c++调用qml中函数的例子
最新推荐文章于 2024-06-28 13:57:59 发布