Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
SetContextProperty of model results in segmentation fault
Kirthivasan last edited by
I have implemented a listview in QML for which the model is implemented in Cpp.
In order to refresh the model, as per QT instruction I have used the setContextProperty function call.
context->setContextProperty(<modelName> , QVariant::fromValue(QList<QObject*>)).
After completion of an operation issued by user on clicking a button, the listview is refreshed with the latest updates.
The model gets refreshed continuously without any issue for 4 or 5 times, after which the execution results in segmentation fault.
The exception that is thrown is as shown below:
Unhandled exception at 0x6BB04E2F (Qt5Cored.dll) in <file.exe>: 0xC0000005: Access violation reading location 0x00000000.
I understand that it is due to segmentation fault. Though how can the setContextProperty function be debugged to root cause the issue.
Please provide your ideas.
Hi and welcome to devnet,
setContextPropertycall looks a bit strange. You seem to want to pass an instance of
QList<QObject *>but its' not really clear.