Solved Qt Quick Application crashing on updating the ListView using QAbstractListModel class
-
I added the full stack trace below
1 QQmlDMCachedModelData::metaCall(QMetaObject::Call, int, void * *) 0x7fffe8114b83
2 loadProperty(QV4::ExecutionEngine *, QObject *, QQmlPropertyData const&) [clone .constprop.350] 0x7ffff71b99ce
3 QV4::QObjectWrapper::getQmlProperty(QV4::ExecutionEngine *, QQmlContextData *, QObject *, QV4::String *, QV4::QObjectWrapper::RevisionMode, bool *, QQmlPropertyData * *) 0x7ffff71ba7da
4 QV4::QQmlContextWrapper::getPropertyAndBase(QV4::QQmlContextWrapper const *, QV4::PropertyKey, QV4::Value const *, bool *, QV4::Value *, QV4::Lookup *) 0x7ffff7193954
5 QV4::QQmlContextWrapper::resolveQmlContextPropertyLookupGetter(QV4::Lookup *, QV4::ExecutionEngine *, QV4::Value *) 0x7ffff71940ed
6 QV4::Moth::VME::interpret(QV4::CppStackFrame *, QV4::ExecutionEngine *, const char *) 0x7ffff71d53bc
7 QV4::Moth::VME::exec(QV4::CppStackFrame *, QV4::ExecutionEngine *) 0x7ffff71d958b
8 QV4::Function::call(QV4::Value const *, QV4::Value const *, int, QV4::ExecutionContext const *) 0x7ffff716e1e5
9 QQmlJavaScriptExpression::evaluate(QV4::CallData *, bool *) 0x7ffff72ef43a
10 QQmlBinding::evaluate(bool *) 0x7ffff72f4b47
11 QQmlNonbindingBinding::doUpdate(QQmlJavaScriptExpression::DeleteWatcher const&, QFlagsQQmlPropertyData::WriteFlag, QV4::Scope&) 0x7ffff72f9805
12 QQmlBinding::update(QFlagsQQmlPropertyData::WriteFlag) 0x7ffff72f6363
13 QQmlObjectCreator::finalize(QQmlInstantiationInterrupt&) 0x7ffff7306442
14 QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt&) 0x7ffff72953e9
15 QQmlEnginePrivate::incubate(QQmlIncubator&, QQmlContextData *) 0x7ffff7295904
16 QQmlDelegateModelPrivate::object(QQmlListCompositor::Group, int, QQmlIncubator::IncubationMode) 0x7fffe8125252
17 QQmlDelegateModel::object(int, QQmlIncubator::IncubationMode) 0x7fffe8125572
18 QQuickItemViewPrivate::createItem(int, QQmlIncubator::IncubationMode) 0x7fffe865288f
19 QQuickListViewPrivate::addVisibleItems(double, double, double, double, bool) 0x7fffe86617f8
20 QQuickItemViewPrivate::refill(double, double) 0x7fffe8653c3a
21 QQuickItemView::componentComplete() 0x7fffe8659088
22 QQmlObjectCreator::finalize(QQmlInstantiationInterrupt&) 0x7ffff73067c1
23 QQmlComponentPrivate::complete(QQmlEnginePrivate *, QQmlComponentPrivate::ConstructionState *) 0x7ffff728e5f1
24 QQmlComponentPrivate::completeCreate() 0x7ffff7290ef7
25 QQmlComponent::create(QQmlContext *) 0x7ffff728e0db
26 QQmlApplicationEnginePrivate::finishLoad(QQmlComponent *) 0x7ffff72fb5cc
27 QQmlApplicationEnginePrivate::startLoad(QUrl const&, QByteArray const&, bool) 0x7ffff72fb7e6
28 QQmlApplicationEngine::load(QUrl const&) 0x7ffff72fba1d
29 main main.cpp 30 0x555555557c5c -
@James-A
i dont think that the code you've posted is causing this issue.The only code which doesn't make sense is the line
anchors.verticalCenter: parent.verticalCenter
in your delegate.
-
I tried changing the delegate to delegate: Text { text: name }
But the issue is persisting -
@James-A
as i said, i don't think that the code you've posted is causing this issue, at least i don't spot an issue.
Try a full rebuild.If the issue persists, try removing single items to check which Item is causing it.
Also your ListView has no size set.
-
I tried deleting the output folder and then rebuild gain , and also tried commenting out individually the code under WiFi_model, from that what I observed is when I remove the below line from the "roleNames()" functions the application is starting , but not updating the data on the ListView
roles[name] = "name";
Again when I try adding it back , the application gets crashed
So I found the line of code which is causing the problem , but not sure why it is causing the crash and what I am missing in itAnd I also set the ListView size as below
anchors.fill: parent
-
@James-A
strange.
Does it work when you rename the enum value fromname
to e.g.NameRole
?QHash<int, QByteArray> WiFi_model::roleNames() const { QHash<int, QByteArray> roles; roles[NameRole] = QByteArrayLiteral("name"); return roles; }
-
Can u also try removing the columnCount implementation completely ? This is not required. Some times this is also a issue.
-
I changed the roleNames() function implementation as suggested above.
I completely removed the commented columnCount() function
But there is no change , still the error exist
-
Issue is coming from index() and parent() method. Comment them.
Also qml code needs correction.
This should work.GroupBox { id: groupBox anchors.fill: parent ListView { anchors.fill: parent model : wifi_model delegate: Text { text: name width: 300;height: 40 font.bold: true } onCountChanged: console.log("count changed: " + count) } }
-
Thanks for pointing it out. Yes it was due to index() and parent() . I removed it completely
Now the application is running