Serialization Made Easy with Qt

Qt Serialization logoThe libQtSerialization library is a Qt extension that makes it really easy to serialize your data in a forward and backward compatible way1.

The library is composed of two sides: the QWriter which helps you serialize data, and the QReader that helps you unserialize data.

The writer is quiet straight forward. Pretty much, all you have to do is call a writeTag() function and the data gets serialized.

The reader is a little more complex so the serialization can support special cases, especially sub-classes (so you can save a tree of classes) and array of classes (your tree may be composed of multiple instances of a given object.)

Implementation Details

The current implementation makes use of stripped down version of the XML file format. It makes use of two tags: <r> which is the root tag, and <v> to represents fields (values). Tags may have one letter named attributes ([f]ile format, major [v]ersion, [m]inor version, [n]ame).

The one draw back at this time is that integers and floating point data are saved in text format. Integers will always be exact, however, floating point may change slightly when reloaded. However, you can always save the data of a floating point as an int32 or int64 if a 1 to 1 precision is required. It is easy to convert using a union, although know that this is not endian compatible.

Note that binary buffers need to first be converted to a string. You can do so using a call to QByteArray::toBase64() (serialization) and to QByteArray::fromBase64() (unserialization.)

QtSerialization::writeTag(w, "data", f_data.toBase64().data());


The libQtSerialization project requires the Qt library 4.7+ and cmake:

  1. cmake, make, and a C++ compiler for the build process
  2. Qt 4.8.1+

Obviously, I suspect you're using Linux. Other Unix systems should be capable of compiling the code. MS-Windows, I have no clue, but I would imagine so. I'll gladly accept comments and patches (comments can be posted here, patches should be offered directly on instead.)


Download the libQtSerialization source code from

We also offer ready to install packages on LaunchPad: Snap CPP (for Ubuntu users.)

Now Ubuntu Packages are available on launchpad (packages).

Programmer Documentation

Search for the libQtSerialization entries under References.

The documentation is also found inline in the .cpp and .h files of the project. Corrections to the documentation are very welcome.


Patches, problems, please report on the page.

If you just want to post a general message, feel free to post a comment on this page.

Projects using this library

Got a project now officially using the libQtSerialization library? Let us know and we'll include a link to your project/product here.

Changes / History

  • Version 0.1.0

This is the first version made available.

In this version, unknown tags are not properly escaped. This means this version will not be fully forward compatible (i.e. files saved with newer versions may not work with this version of the library and thus may not be reloadable.)


Offer support to save floating points without any loss of data.

Skip unknown tags properly and silently.

Ignore unknown attributes properly and silently (this should already work, although I did not test properly yet.)

  • 1. Being foward and backward compatible means you should be able to load your serialized data from newer and older versions of your software without having to tweak the serialized data before hand.

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly