[Development] QAbstractItemModel's meta-object got changed in QtQuick

Axel Spoerl axel.spoerl at qt.io
Mon Aug 14 15:25:57 CEST 2023


Hi,

The meta object doesn’t change during execution. The messages probably mean, that upon app close, the custom class (inheriting from QObject) is already deleted. Only a QObject is left, which is what className() correctly reports.

Maybe throw a qDebug() in the custom class destructor, to check if it is reached too early. I personally haven’t seen error logs of that kind. It doesn’t seem right that the custom class gets deleted, with its connections still being reported as active. Unless there is a bug in the custom class implementation, I suggest to file a bug report with a minimal reproducer.

Cheers
Axel

On 14 Aug 2023, at 15:06, Ziming Song <s.ziming at hotmail.com> wrote:

Hi,

I’m playing with QtQuick TreeView with custom QAbstractItemModel in C++. The program runs fine, except some error logs when program exits:

qt.core.qobject.connect: QObject::disconnect: No such signal QObject::rowsAboutToBeRemoved(QModelIndex,int,int)
qt.core.qobject.connect: QObject::disconnect: No such signal QObject::columnsAboutToBeRemoved(QModelIndex,int,int)
qt.core.qobject.connect: QObject::disconnect: No such signal QObject::rowsAboutToBeInserted(QModelIndex,int,int)
qt.core.qobject.connect: QObject::disconnect: No such signal QObject::columnsAboutToBeInserted(QModelIndex,int,int)
qt.core.qobject.connect: QObject::disconnect: No such signal QObject::rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)
qt.core.qobject.connect: QObject::disconnect: No such signal QObject::columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)
qt.core.qobject.connect: QObject::disconnect: No such signal QObject::rowsMoved(QModelIndex,int,int,QModelIndex,int)
qt.core.qobject.connect: QObject::disconnect: No such signal QObject::columnsMoved(QModelIndex,int,int,QModelIndex,int)
qt.core.qobject.connect: QObject::disconnect: No such signal QObject::layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)
qt.core.qobject.connect: QObject::disconnect: No such signal QObject::layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)
qt.core.qobject.connect: QObject::disconnect: No such signal QObject::modelReset()

This is what I found.

Error messages come from QItemSelectionModelPrivate::initModel, which is called (at least) twice, one during app start to set the model and connect some signals, one during app close to disconnect signals and set model to NULL.

At app starting, m->metaObject()->className() is correct (my custom model class name).

At app closing, m->metaObject() value changes, and m->metaObject()->className() is “QObject”, which doesn’t have those signals, thus the error message.

Can metaobject be modified during execution? If so, why?

Thanks in advance
songziming
--
Development mailing list
Development at qt-project.org<mailto:Development at qt-project.org>
https://lists.qt-project.org/listinfo/development

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230814/2c6ab699/attachment-0001.htm>


More information about the Development mailing list