3

以下是为将 QML 文档加载到 c++ 而编写的代码。

  QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    // Create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();


    app->setScene(root);
}

如何访问 QMLdocument 的对象,例如按钮等;来自 C++。我需要访问它们以查找 QML 文档中特定对象的内存地址。

4

1 回答 1

3
ImageView* iv= root->findChild<bb::cascades::ImageView*>("myImageView");

在 QML 中

 ImageView 
 {
      // ...
      objectName: "myImageView"
 }

编辑:不要忘记清理和重建项目。

于 2013-11-13T11:55:51.987 回答