我有一个ListView用rootModelQml 内部命名的自定义 C++ 模型初始化的。模型继承QAbstractListModel并将 a 定义QVector<customType>为私有成员以填充模型。
在 my 中,ApplicationWindow我创建了一个,Dialog在其中更改模型并调用setList()函数来更新它。这工作正常。
我还想将模型的大小连接到 aScrollView的int属性。此属性将定义childrena 的RowLayout。
问题是,当我尝试将此属性绑定到模型的大小时,应用程序崩溃了。
仅供参考,模型的所有修改都遵循 Qt 的规则。rowCount()是Q_INVOKABLE。我也尝试过使用onModelChanged处理程序,但这没有用(我在文档中检查了这个信号是在发出时modelReset()发出的,这是setList()通过内部发生的endResetModel()
我相信这是一个简单的过程(已经在我的项目中多次执行了属性绑定)但没有按预期工作。
我引用了我的项目的一些示例代码。
//main.qml
ConfiguredChannels{
id: configuredList
anchors{
left: parent.left
top: devices.bottom
right: tabs.left
bottom: parent.bottom
}
}
TabArea {
id: tabs
y: toolBar.height
x: parent.width / 8
anchors {
top: toolBar.bottom …Run Code Online (Sandbox Code Playgroud)