I have a QList contains a list of OpenCv::Mat. I'd like to write the QList to a file and read a file into a QList with QDataStream.
Here is part of my code:
// Variables declarations
QList<Mat> myList;
cv::Mat someData;
QString fileName = "list.dat";
QFile file(fileName);
QDataStream out(&file);
QDataStream in(&file);
// Storing some data into the list
myList.append(someData);
myList.append(someData);
myList.append(someData);
// Writing the list to a file
file.open(QIODevice::WriteOnly);
out << myList;
file.close();
// Reading a file to the list
file.open(QIODevice::ReadOnly);
in >> myList;
file.close();
And I received two errors:
error: C2678: binary '>>': no operator found which takes a left-hand operand of type 'QDataStream' (or there is no acceptable conversion)
error: C2678: binary '<<': no operator found which takes a left-hand operand of type 'QDataStream' (or there is no acceptable conversion)
Any suggestions?
QDataStream & operator>>()
has no overload forQList<Mat>
. you have to push_back (or so) in a loop... – user1810087QDataStream& operator>>(QDataStream&, const QList<Mat>&);
andQDataStream& operator<<(QDataStream&, const QList<Mat>&);
– Jonas