Main Page · All Classes ·
QXmlPutGet Documentation


QXmlPutGet is a library for convenient and intuitive writing and reading of XML. This is a quick and more technical introduction to QXmlPutGet. For a practically oriented tutorial, visit


The library consists of two classes: writing is done by QXmlPut and reading by QXmlGet.

Both classes work on their current element. In QXmlPut this is the element that was previously created (e.g. with QXmlPut::putString), in QXmlGet this is the element which was previously navigated to (e.g. with QXmlGet::find). Due to this concept, writing and especially reading may not always happen in one single call, but multiple calls, that base on the internal state (the current element) of the QXmlPut/QXmlGet instance.

In QXmlPut the navigation is tied to the creation of tags (QXmlPut::putSingleTag, QXmlPut::putString, QXmlPut::descend,...).

In QXmlGet the navigation is done by finding tags by name (QXmlGet::find, QXmlGet::findNext), and possibly descending into them (QXmlGet::descend, QXmlGet::descended).

Both classes have functions that allow direct jumps inside the underlying QDomDocument (QXmlGet::goTo, QXmlPut::goTo, QXmlGet::element, QXmlPut::element). Use these functions only when necessary, as it's not the way normal linear navigation should be carried out.

In QXmlGet, once there is a current element available, it can be accessed e.g. with QXmlGet::getString, QXmlGet::getInt, QXmlGet::getAttributeString etc.

In QXmlPut, the current element (which was created with QXmlPut::putString("tagName", "string content"), for example), can further be modified by setting attributes, e.g. with QXmlPut::setAttributeString.

Saving and Loading UI State

The QXmlPutGet library offers very convenient facilities to save and load the state of QWidget-based UIs. Methods such as for example QXmlPut::saveLineEdit or QXmlPut::saveAbstractSlider (and the corresponding QXmlGet::loadLineEdit / QXmlGet::loadAbstractSlider) methods allow saving the states of such widgets. Even more convenient is the method-pair QXmlPut::saveWidget and QXmlGet::loadWidget, which automatically detects the type and saves/loads the widget state. If you wish to save/load all child widgets in a parent widget, consider using QXmlPut::saveWidgetsRecursive and QXmlGet::loadWidgetsRecursive, which also allow specifying a name filter prefix/suffix, and an exclusion list.