Unsolved Data serialization
-
I want to write on file using textedit based on the concept of data serialization. What can I do?
-
Hello @shree_qt
Looks like you need to take a look at QDataStream class doc ,
http://doc.qt.io/qt-4.8/qdatastream.html#details
There is an example with explanation in this doc:
Example (write binary data to a stream):
QFile file("file.dat"); file.open(QIODevice::WriteOnly); QDataStream out(&file); // we will serialize the data into the file out << QString("the answer is"); // serialize a string out << (qint32)42; // serialize an integer
Example (read binary data from a stream):
QFile file("file.dat"); file.open(QIODevice::ReadOnly); QDataStream in(&file); // read the data serialized from the file QString str; qint32 a; in >> str >> a; // extract "the answer is" and 42
Hope this can help !
-
In addition to previous post, You can look at http://www.ics.com/blog/object-serialization-and-persistence-using-qdatastream. It has nice example to do the same. If you need more help do let me know.
-
This is a long-standing (6.5 years now) feature request, see https://bugreports.qt.io/browse/QTBUG-9258 but it would require a deep change in the underlying framework of QTextDocument.
If you are interested only in writing you can use QTextDocumentWriter but there is no corresponding reader.
You could implement a manual solution if you know what resources are used in the document
-
I am very beginning in qt and c++ also. Thanks for your post . I will try.
-
This post is deleted!