qdatastream

Append a QByteArray to QDataStream?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 14:08:02
I have to populate a QByteArray with different data. So I'm using the QDataStream . QByteArray buffer; QDataStream stream(&buffer, QIODevice::WriteOnly); qint8 dataHex= 0x04; qint8 dataChar = 'V'; stream << dataHex<< dataChar; qDebug() << buffer.toHex(); // "0456" This is what I want However, I would also like to append a QByteArray to the buffer . QByteArray buffer; QDataStream stream(&buffer, QIODevice::WriteOnly); qint8 dataHex= 0x04; qint8 dataChar = 'V'; QByteArray moreData = QByteArray::fromHex("ff"); stream << dataHex<< dataChar << moreData.data(); // char * QByteArray::data () qDebug()

How to open a bin file in Python using QDataStream

江枫思渺然 提交于 2019-12-02 00:53:43
I've got a bin file that was encoded in an application that I need to get access to and convert to a csv file. I've been given the documentation, but am not sure how to access the contents of this file in Python. Here are some of the details about how the dataset was serialized Datasets.bin is a list of DataSet classes serialized using Qt's QDataStream serialization using version QDataStream::Qt_4_7. The format of the datasets.bin file is: quint32 Magic Number 0x46474247 quint32 Version 1 quint32 DataSet Marker 0x44415441 qint32 # of DataSets n DataSet DataSet 1 DataSet DataSet 2 . . . .

How to serialize a QAbstractItemModel into QDataStream?

那年仲夏 提交于 2019-12-01 18:01:41
I've set up a QAbstractItemModel and filled that with data. My QTreeView widget displays every data in that model properly. Now, I would like to store that model serialized in a binary file (and later of cource load that binary file back into a model). Is that possible? The particulars of model serialization depend somewhat on the model's implementation. Some gotchas include: Perfectly usable models might not implement insertRows / insertColumns , preferring to use custom methods instead. Models like QStandardItemModel may have underlying items of varying types. Upon deserialization, the