实现要求,数据显示list列表5000条,qml界面中与案件可以更改数据内容,界面中显示list数据,滑动过程中数据几百个的时候总是提示错误信息:“TypeError: Result of expression 'model.modelData' [undefined] is not an object.
段错误(吐核)”
qml:
Text {
text:model.modelData.name
}
ListView {
id: view
anchors.fill: parent
model: modelDataTable.openFile()
delegate: delegate
interactive: true
clip: true
//orientation: ListView.Horizontal
//highlight: highlight
}//end of ListView
.h
Q_INVOKABLE QList<QObject*> openFile();
.cpp
QList<QObject*> DataObject::openFile()
{
dataListTest.clear();
QString str;
for(int i = 1; i<=5000; i++)
{
str = str.setNum(i);
dataListTest.append(new DataObject(str, "red"));
}
return dataListTest;
}
2 个解决方案
#1
自己顶,求助求助
#2
QList<QObject*>属于QVariant的范围吗?
#1
自己顶,求助求助
#2
QList<QObject*>属于QVariant的范围吗?