首页 > 解决方案 > 通过 id 或 objectName 在 qml 中查找对象

问题描述

如何通过 objectName 或 id 在 qml 中找到元素?我想实现类似的功能

Item {
    id: myItem
}
MyItemClass {
   onStart: {
      myclass.add_new_obj (myItem.toString)
   }
   onJobDone: {
       item_qml_id.width = width_qml
       // here item_qml_id = Item_QMLTYPE_111(0x1ee54f12312), can i find object using this value?
   }
}

我在 C++ 中的信号看起来像:

void jobDone(QString item_qml_id, int width_qml)

标签: c++qtqml

解决方案


推荐阅读