
XmlUi is a set of classes which simplify building the menu bar, toolbars and context menus in Qt4. It allows to merge actions from multiple components and define the layout of menus and toolbars using simple XML files.
The XmlUi classes are most useful in applications which embed various kinds of UI components, for example views for editing various kinds of documents or custom plug-ins. The main window's menus and toolbars can be automatically created by merging the layout of all components.
The XML files decribing the layout are usually compiled into the executable as resources. External files can also be used, so that users can modify them in order to customize the menus and toolbars. However XmlUi provides no UI for customizing the layout.
XmlUi was inspired by the KXMLGUI classes from the KDE libraries, but it's much simpler and doesn't require anything else than Qt4.
XmlUi consists of two classes. The Builder is associated with a main window and automatically creates its menu bar and toolbars. The Client is a container for a single component's actions; it also stores the layout of menus and toolbars provided by the component. Clients can be dynamically added and removed from the builder. The layout of menus and toolbars defined by all clients is merged into a single structure.
Note that a new version of XmlUi is currently under development as part of version 1.0 of WebIssues. It integrates the Modern Qt style and features a toolstrip component, which can be used as a replacement for menus and toolbars.
You can find the full documentation for this article at doc.mimec.org/articles/xmlui/. It is also included in the source package.
1.1 (2009-11-23)
1.0 (2008-06-23)
Use this forum to post comments for this article.
This code can be freely used and modified in both open source applications (including GPL) and commercial applications. If you find it useful, please consider donating to mimec.org!