There is a QVector <data> obj . How best to implement binary file I / O?

 class data{ int var1; QString var2; bool var3; bool var4; void someFunc(); }; 

Closed due to the fact that it is necessary to reformulate the question so that it was possible to give an objectively correct answer by the participants post_zeew , pavel , αλεχολυτ , aleksandr barakin , HamSter Oct 25 '16 at 18:22 .

The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    Overload the operators << and >> for the class, and write / read the vector in QFile via QDataStream standard way using the same operators.

    Here article on Habré about serialization of objects in Qt.

    • Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky
    • @NicolasChabanovsky, and yet, the advice is correct. - aleks.andr