Simple XML-based UI builder for Qt4

Submitted by mimec on 2012-05-28


This library provides a tool strip widget, replacing classic menu bar and toolbars, and facilities for defining and merging the layout of actions from multiple components, using simple XML files.

Tool strips have several advantages over traditional menu bar and toolbars. Unlike menus, all most commonly used actions can remain accessible with a single mouse click, while it is still possible to put less commonly used actions in popup menus attached to tool buttons. On the other hand, actions can be logically grouped and visually distinguished much better than in a traditional toolbar, which is simply a long row of similar looking icons.

The XmlUi library also provides a set of classes which simplify building the tool strip and popup menus. The layout can be defined using XML files which allows changing them easily without modifying the code. They also allow the layout of actions to be merged from multiple components, which is most useful in applications which embed various types of views or custom plug-ins.

The first version of XmlUi was inspired by the KXMLGUI classes from the KDE libraries. Later the tool strip widget was added and a simplified version of the Windows Modern Style was incorporated to provide a better look and feel for tool strips and menus. If you prefer to use traditional menu bar and toolbars, you can use the older version of XmlUi.


You can find the full documentation for this article at It is also included in the source package.


2.1 (2012-05-28)

  • fixed toolstrip appearance on Mac OS X
  • added the execMenu() and toolStrip() helper functions
  • display shortcut of default menu item in button's tooltip when available

2.0 (2011-12-19)

  • added the new toolstrip control
  • integrated the modern Windows style

1.1 (2009-11-23)

  • added: support for toolbar buttons with menus
  • added: styling splitters in main windows
  • fixed: improved appearance of styled tab widgets
  • fixed: painting undocked toolbars

1.0 (2008-06-23)

  • initial version


This code can be freely used and modified in both open source applications (including GPL) and commercial applications.

Extensible SQLite driver for Qt4

Submitted by mimec on 2012-04-26

This library is an alternative SQLite driver for Qt4 which includes its own copy of SQLite and allows extending it by implementing custom functions, collations, etc. It is very similar to the standard SQLITE driver which is part of the Qt framework.

The main difference is that upon opening a database, it registers custom collations for case-insenitive comparisions and a function implementing the REGEXP operator. These are the most important two feature missing from standard SQLite implementation.

Why create another driver and not just use the existing one? The reason is that it is currently not possible to call the sqlite_ functions from the SQLite API, because they are not exported when the SQLite library bundled with Qt is used. Unfortunately, this is the case for many platforms, including Windows. See QTBUG-18084 and my article about collation in SQLite for more information.

To workaround this limitation, the SQLITEX driver comes with it's own bundled SQLite library. However, it can also be configured to use the system sqlite library when it's possible.

The SQLITEX driver is used by WebIssues Client 1.0 in place of the RDB component used in previous version.


You can find the full documentation for this component at It is also included in the source package.


1.1 (2012-04-26)

  • updated SQLite to 3.7.11
  • updated the SQLite driver to Qt 4.8
  • removed the usage of QString::fromUtf16()

1.0 (2011-12-19)

  • initial version


This code is licensed under the GNU Lesser General Public License, for compatibility with code from Qt which it incorporates, and to make it possible to use it in commercial applications.

Legacy MFC components

Submitted by mimec on 2012-03-15


All components listed below were written by me between 2002 and 2005 when I used the MFC framework for developing various applications. I published them first on the portal, then on my personal website. At that time they were very popular.

Today I no longer maintain or support them and I can't even guarantee that they will work with latest versions of MFC. However, they are still moderately popular and can still be useful to someone, so I'm keeping a list of those components for reference.

Each of the components includes a simple demo application and a brief documentation (also included in demo packages). They can be freely used for any purposes, including commercial use.

Multi-column tree view

Simple tree view with columns and horizontal scrolling

  • Very simple - only 16 KB of code
  • Used just like the standard CTreeView, also a version for dialog windows
  • Columns header, horizontal scrolling, grid lines, full-row selection mode
  • Standard look under all OS versions
  • Source code · Demo project · Documentation

Multi-threaded SDI applications

Creating multi-threaded SDI applications with multiple windows

  • Opening documents in individual SDI windows created in separate threads
  • The Window menu which can be used to switch to other windows
  • Improved registering of file extensions and opening documents from the Explorer
  • Full integration with the document/view architecture of the MFC library
  • Source code · Demo project · Documentation

IE-style menu and toolbar

IE-style menu bar and toolbar with 32-bit images

  • Menu bar which can be placed in a Rebar control, with full mouse and keyboard support
  • 3D or flat style depending on system version and settings
  • Displaying images from 16-colors to 32-bit with alpha channel
  • Easy creating of pop-up menus
  • Source code · Demo project · Documentation

HotProp control

A flexible properties control with modern look

  • Numeric, text and boolean properties, drop-down lists of options
  • Two layout modes: single-line and double-line
  • Two visual styles: 3D of flat (Office XP style)
  • Graphical properties with custom drawing procedures
  • Dynamic adding, removing and hiding properties
  • Source code · Demo project · Documentation

Multi-page interface

User interface with many views, tabs and splitters

  • Easy creating of windows with many views using simple macros
  • Improved splitter redrawing the views while dragging
  • Dividing the interface into many pages implemented as separate MDI child windows
  • Freely nested sub-pages with automatically created tabs to switch them
  • Source code · Demo project · Documentation

Simple template-based relational database

Submitted by mimec on 2010-10-08


RDB is a set of class templates implementing simple, generic and fast collections of objects called tables. Each table can store objects of any class with one or more integer attributes called keys. The table has a separate index for each key for fast retrieving and iterating items.

In addition, this package contains adapter classes for using RDB tables with the Qt Model/View architecture.

Depending on your needs, you can use just the 'core' components of RDB, or use them together with the model components. The core RDB components have no external dependencies. The model components require Qt 4.2 or newer.

Core RDB classes

An RDB table is an indexed collection of objects, similar to a hashed map, but with the possibility to have multiple indexes for different attributes in one table. It can be used to organize data in memory in a similar way to a relational database. Note that RDB provides no support for serializing data or for binding with an external database.

Many applications need to store complex data structures in memory. They often do so by using collections of objects, which in turn contain their own collections of objects, forming a tree structure of relations. The downside is that in order to find data stored on a deep level of the tree, you have to traverse through all parent branches, which may lead to inefficient and difficult to understand code.

The situation gets even worse if the data structure is not a tree, but contains cross-references, circular dependencies and many-to-many relations. This makes memory management difficult and error-prone, especially in a language such as C++ with no automatic garbage collection.

A relational database is a simple and well established model of storing data with complex relations. Databases are excellent for storing persistent data, but cannot be used for working with data which has to be stored in memory for performance reasons. Even if an application works with a database backend, it still usually maps retrieved data to collections of objects, which are subject to the problems described above.

The purpose of RDB is to combine the efficiency and ease of use of simple containers like lists and maps with the idea of a relational database which uses keys and indexes for modeling relations between data.

Adapters for the Qt Model/View architecture

The RDB package contains adapter classes for using tables with the Qt Model/View architecture in an easy and comfortable way. This is useful if your application needs to displays various lists and trees of data stored in RDB tables. The adapter model automatically populates the view, and also provides support for automatic sorting and filtering and makes customizing columns in the view easy.

The Model/View architecture in Qt is an excellent and powerful solution, but implementing a model from scratch is not very comfortable. One of the problems is that the indexes used to identify cells are based on the physical row and column number in the view, which has to be translated to the appropriate item of data. This can be difficult when rows can be sorted, columns can be reordered and especially if the view is a tree with multiple levels of items.

The RDB::TableItemModel class solves this problem by acting like an additional layer between QAbstractItemModel and simplified models called table models. Table models operate on item identifiers (which simply correspond to keys in the RDB tables) and column identifiers, without having to know the layout of rows and columns in the view. In addition, each table model is associated with a single level of items in the tree. This way you can, for example, create a list of all persons and a tree of persons grouped by company, and reuse the same table model in both these views.


You can find the full documentation for this component at It is also included in the source package.


1.2 (2010-10-08)

  • added the findRow utility function
  • fixed wrong sorting by non-unique column
  • fixed validation of input data

1.1 (2009-11-23)

  • added: method for finding a cell in the model
  • added: default argument values for TableItemModel methods
  • fixed: possible crashes when invalid model indexes are passed
  • fixed: prevent updating the view when columns don't change

1.0 (2008-06-09)

  • initial version


This code can be freely used and modified in both open source applications (including GPL) and commercial applications.

Modern Qt style for Windows

Submitted by mimec on 2008-07-14


The WindowsModernStyle changes the look of toolbars and menus to a style similar to MS Office 2003 and some .NET applications. Depending on the selected color scheme of Windows XP and Vista, they will automatically use the blue, silver or green colors. Also when the Windows Classic style is used, the toolbars and menus will adjust their look to the current color scheme.

In addition, this style also changes the look of:

  • docked windows, including their title bars and tabs used when multiple docked windows are stacked together
  • tab widgets located within a main window (tab widgets placed in dialogs and other windows are not affected)
  • splitters located within a main window
  • toolbox widgets, including both item headers and background of pages

All other widgets are not affected and are rendered using the native Windows style (Vista, XP or classic Windows, depending on the OS version).

The style can be included in an existing application or compiled as a plugin library. This package also contains a demo program using this style.

WindowsModernStyle requires Qt 4.3 or newer, compiled with the Windows XP and Windows Vista styles enabled.

Note: a new, simplified version of the Modern Qt style is now part of the XmlUi component.


You can find the full documentation for this article at It is also included in the source package.


1.1 (2009-11-23)

  • added: support for toolbar buttons with menu
  • fixed: painting undocked toolbars
  • added: styling splitters in main window
  • fixed: improved appearance of styled tab widgets

1.0 (2008-07-14)

  • initial version


This code can be freely used and modified in both open source applications (including GPL) and commercial applications.