【qml】在C++中获取qml中的对象
直接上代码:
int main(int argc, char *argv[])
{QGuiApplication app(argc, argv);QQmlApplicationEngine engine;engine.load(QUrl(QStringLiteral("qrc:/main.qml")));QObject *pRoot = engine.rootObjects().first();QObject *pButton = pRoot->findChild<QObject *>("testButton");if( pButton ){。。。;}return app.exec();
}
【qml】在C++中获取qml中的对象
直接上代码:
int main(int argc, char *argv[])
{QGuiApplication app(argc, argv);QQmlApplicationEngine engine;engine.load(QUrl(QStringLiteral("qrc:/main.qml")));QObject *pRoot = engine.rootObjects().first();QObject *pButton = pRoot->findChild<QObject *>("testButton");if( pButton ){。。。;}return app.exec();
}