如何将一个 QQuickItem 扩展作为子扩展添加到另一个 QQuickItem 扩展?
How to add a QQuickItem extension as a child to another QQuickItem extension?
我目前正在为Qt Quick建立一个C++工厂。我需要能够将工厂生成的子项添加到另一个自定义 QQuickItem 中,如下所示:
class Bar : public QQuickItem {
Q_Object
Bar(QQuickItem * parent = 0) : QQuickItem(parent) {
// Generate some config called barConfig
QQuickItem * newChild = FooFactory(barConfig);
// Add child here?
}
}
虽然实际上,有一个管理工厂配置的BarModel
,但这在这里似乎无关紧要。那么,如何将我的newChild
添加为Bar
实例的子实例呢?
使用 setParentItem()
:
Bar(QQuickItem * parent = 0) : QQuickItem(parent) {
// Generate some config called barConfig
QQuickItem * newChild = FooFactory(barConfig);
newChild->setParentItem(this);
}
相关文章:
- 是否可以通过C++扩展强制多个python进程共享同一内存
- static_assert在宏中,但也可以扩展到可以用作函数参数的东西
- 如何将这个C++哈希表转换为动态扩展和收缩,而不是使用硬设置的最大值
- 扩展光电二极管探测器以支持多个传感器
- C++中的VLA,扩展名为std=C++11
- OpenGL 和 GLM 矩阵无法正确扩展,总是按比例缩小
- 基于范围的 for 循环:迭代使用一个元素扩展的向量
- C++返回 Numpy 数组的 Python 扩展模块
- 扩展可变参数模板中的变量名称
- 扩展C++生成的代码的模板参数类型名称
- 我想通过带有C++和Python的插件创建一个可扩展的应用程序
- VSCode IntelliSense无法识别SDL框架的SDL_image扩展库
- 将元组类型扩展为可变参数模板?
- 如何按文件扩展名引用文件夹中的文件
- 构造函数中的 QQuickItem 父项 null
- HDF5Cpp 扩展复合数据集超板问题
- MSVC中的宏观扩展问题
- 如何从C++扩展的QQuickItem创建QQuickWindow作为子窗口?
- 如何将一个 QQuickItem 扩展作为子扩展添加到另一个 QQuickItem 扩展?
- 如何在扩展的QQuickItem中与模型交互