Qt qml -如何在其定义中使用组件
Qt qml - how to use component in its definition?
我必须在qml
中实现TreeView
。基本上,因为每个子树只是TreeView
本身,我想在TreeView
定义中使用TreeView
组件(这是结束的Repeater
)。
这是我引用我正在定义的组件的代码的一部分。
你可以看到rootDelegate
实际上是Component
中的id
。
问题是Qt给出错误无法将QQuickRow分配给QQmlComponent
Repeater {
model: childrens
delegate: rootDelegate
}
TreeView.qml
import QtQuick 2.0
Component {
id: rootDelegate
Column {
Row {
id: itemControl
spacing: 2
Rectangle {
anchors.verticalCenter: parent.verticalCenter
gradient: Gradient {
GradientStop { position: 0.0; color: "#EEEEEE" }
GradientStop { position: 1.0; color: "#404040" }
}
width: openChar.implicitWidth
height: openChar.implicitHeight - 6
radius: 3
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
}
Text {
id: openChar
text: "+"
color: "black"
anchors.centerIn: parent
}
}
Rectangle {
height: 1
color: "#A0A0A0"
width: 10
anchors.verticalCenter: parent.verticalCenter
}
Text {
text: model.text
color: "white"
}
}
Repeater {
model: childrens
delegate: rootDelegate
}
}
}
您试图在自身中递归地使用Сomponent,这在Qml
相关文章:
- 在提升multi_index容器中,是否定义了"default index"?
- #定义c-预处理器常量..我做错了什么
- 用C++中的一个变量定义一个常量
- 部分定义/别名模板模板参数
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- 基于 QML 模型的组件在 android 上具有未定义的 modelData
- 实体组件系统未定义的符号
- 如何在Maya中选择自定义网格组件后立即发布用户事件
- 虚幻引擎4:UShape组件给出错误"标识符未定义"。我能做什么?
- 元组的定义和初始化,其组件属于同一模板化类,但具有不同的专用化
- QML:如何将动态创建的组件与自定义的内部对象一起使用
- 如何在方法中将自定义 WinRT 类型从 c# 传递到 c++ Windows 运行时组件
- 通过 [ " " ] 或 [int] 为自定义类C++访问组件
- 定义/使用由预设组件构建的类(在c++中)
- 定义强连接组件
- 无法动态链接到自定义bpl中的组件
- Qt qml -如何在其定义中使用组件
- 如何从c++ COM组件返回和使用自定义结构对象到c#应用程序
- c++ /QML:如何为动态创建的组件定义和处理多个上下文
- 如何定义COM组件类的实现