Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Saving Qt application data to a Custom Binary format.



  • Hi,
    I am working on an application that does a lot of drawing and multimedia manipulation .I want to be able to save my data ( images /videos/..) in one file with our custom format ( .fmt for example) .I know QDataStream can write to a file but how can I have Images and Videos encapsulated within my binary file so that when a user saves the data he can later open and play it.Is there a possible way to do this?

    My search so far has pointed me to different ways to serialize data but I haven't seen anything that shows how to serialize multimedia.Am I approaching this the wrong way ?Any input will be appreciated.

    Thanks.



  • It's easy to do. I have used this approach to write data to mifare cards.
    You should create a header, similar to a ini file or http header. In this header you can list all the file names with size. For example

    filename0=a.txt
    filesize0=123
    filename1=b.jpg
    filesize1=12345

    After that you should write the header, a empy row, and the all files.



  • Thanks for the reply mrdebug,
    I don't quite get how your method here works though,how does the header encapsulate my videos and images is not clear yet.Can you explain more or point to a detailed resource to learn about that?

    Thanks.



  • For example if you have to write in one container file two files, file01.mpg, size 100 bytes, and file02.bmp size 200 bytes, you fill create a file with header + empy row, file01 and file 02. Total size is header size + empy row+ file01 size+ file02 size.
    If you have to modify one file for example file01 you have to rewrite all.

    what are you working on?


Log in to reply