Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Generate assert failure when qmodelindex is put into qdatastream...
Daryong last edited by
I am trying to put qmodelindex into qdatastream and I get the following error:
What should I do?
< source >
QDataStream ds(&ba, QIODevice::ReadWrite);
ds << v;
Module : 5.7.1
File : global\gglobal.cpp
ASSERT failure in QVariant::save "Invalid type to save", file kernel\qvariant.cpp, line 2144
I don't think QModelIndex storing in stream is supported. Since save operation returns false for QModelIndex, it must be crashing. May be you can get the row,column values from QModelIndex and save them in stream. Also as side note, it is not a good idea to store the QModelIndex. See the warning message in Qt documentation for QModelIndex.