Qt Lite

Qt Lite is an initiative driven by The Qt Company striving for smaller and leaner Qt builds. It utilizes the new configuration system introduced with Qt 5.8 to create custom builds stripped of features or classes that aren’t needed for a given application. Focus is mostly on Embedded Linux with the goal of making Qt a feasible option on smaller systems. In this post we will have a look at the current state of affairs and we will provide guidance on how to experiment with Qt Lite on your own.

Qt Lite consists of two parts: The first part are changes to the Qt source code and configuration system itself to allow for compiling certain aspects out. This is part of the Open Source code base. The second part is a UI tool to manage build configurations which is part of “Qt for Device Creation”. In this post we will have a look at the Open Source side of things.

What is available?

Qt Lite defines “features” which can be enabled or disabled. This happens via the regular configure script contained in the Qt source base. Qt 5.9 adds an option for listing all available features. Currently there are around 190 feature switches. Most of these are in qtbase and qtdeclarative. Qt 5.9.1 will make the output more accessible by breaking it down into sections.

The following listing shows the full output of configure --list-features for your convenience.

$ ./configure --list-features
abstractbutton .......... Abstract base class of button widgets, providing functionality common to buttons.
abstractslider .......... Common super class for widgets like QScrollBar, QSlider and QDial.
accessibility ........... Provides accessibility support.
action .................. Provides widget actions.
animation ............... Provides a framework for animations.
appstore-compliant ...... Disables code that is not allowed in platform app stores
bearermanagement ........ Provides bearer management for the network stack.
big_codecs .............. Supports big codecs, e.g. CJK.
buttongroup ............. Supports organizing groups of button widgets.
calendarwidget .......... Provides a monthly based calendar widget allowing the user to select a date.
checkbox ................ Provides a checkbox with a text label.
clipboard ............... Provides cut and paste operations.
codecs .................. Supports non-unicode text conversions.
colordialog ............. Provides a dialog widget for specifying colors.
colornames .............. Supports color names such as "red", used by QColor and by some HTML documents.
columnview .............. Provides a model/view implementation of a column view.
combobox ................ Provides drop-down boxes presenting a list of options to the user.
commandlineparser ....... Provides support for command line parsing.
commandlinkbutton ....... Provides a Vista style command link button.
completer ............... Provides completions based on an item model.
concurrent .............. Provides a high-level multi-threading API.
contextmenu ............. Adds pop-up menus on right mouse click to numerous widgets.
cssparser ............... Provides a parser for Cascading Style Sheets.
cups .................... Provides support for the Common Unix Printing System.
cursor .................. Provides mouse cursors.
d3d12 ................... Provides a Direct3D 12 backend for the Qt Quick Scenegraph
datawidgetmapper ........ Provides mapping between a section of a data model to widgets.
datestring .............. Provides convertion between dates and strings.
datetimeedit ............ Supports editing dates and times.
desktopservices ......... Provides methods for accessing common desktop services.
dial .................... Provides a rounded range control, e.g., like a speedometer.
dialog .................. Base class of dialog windows.
dialogbuttonbox ......... Presents buttons in a layout that is appropriate for the current widget style.
dirmodel ................ Provides a data model for the local filesystem.
dockwidget .............. Supports docking widgets inside a QMainWindow or floated as a top-level window on the desktop.
dom ..................... Supports the Document Object Model.
draganddrop ............. Supports the drag and drop mechansim.
effects ................. Provides special widget effects (e.g. fading and scrolling).
embedded ................ Enables the embedded build configuration
errormessage ............ Provides an error message display dialog.
filedialog .............. Provides a dialog widget for selecting files or directories.
filesystemiterator ...... Provides fast file system iteration.
filesystemmodel ......... Provides a data model for the local filesystem.
filesystemwatcher ....... Provides an interface for monitoring files and directories for modifications.
fontcombobox ............ Provides a combobox that lets the user select a font family.
fontdialog .............. Provides a dialog widget for selecting fonts.
formlayout .............. Manages forms of input widgets and their associated labels.
freetype ................ Supports the FreeType 2 font engine (and its supported font formats).
fscompleter ............. Provides file name completion in QFileDialog.
ftp ..................... Provides support for the File Transfer Protocol in QNetworkAccessManager.
gestures ................ Provides a framework for gestures.
graphicseffect .......... Provides various graphics effects.
graphicsview ............ Provides a canvas/sprite framework.
groupbox ................ Provides widget grouping boxes with frames.
highdpiscaling .......... Provides automatic scaling of DPI-unaware applications on high-DPI displays.
http .................... Provides support for the Hypertext Transfer Protocol in QNetworkAccessManager.
iconv ................... Provides internationalization on Unix.
identityproxymodel ...... Supports proxying a source model unmodified.
im ...................... Provides complex input methods.
image_heuristic_mask .... Supports creating a 1-bpp heuristic mask for images.
image_text .............. Supports image file text strings.
imageformat_bmp ......... Supports Microsoft's Bitmap image file format.
imageformat_jpeg ........ Supports the Joint Photographic Experts Group image file format.
imageformat_png ......... Supports the Portable Network Graphics image file format.
imageformat_ppm ......... Supports the Portable Pixmap image file format.
imageformat_xbm ......... Supports the X11 Bitmap image file format.
imageformat_xpm ......... Supports the X11 Pixmap image file format.
imageformatplugin ....... Provides a base for writing a image format plugins.
inputdialog ............. Provides a simple convenience dialog to get a single value from the user.
itemmodel ............... Provides the item model for item views
itemviews ............... Provides the model/view architecture managing the relationship between data and the way it is presented to the user.
keysequenceedit ......... Provides a widget for editing QKeySequences.
label ................... Provides a text or image display.
lcdnumber ............... Provides LCD-like digits.
library ................. Provides a wrapper for dynamically loaded libraries.
lineedit ................ Provides single-line edits.
listview ................ Provides a list or icon view onto a model.
listwidget .............. Provides item-based list widgets.
localserver ............. Provides a local socket based server.
mainwindow .............. Provides main application windows.
mdiarea ................. Provides an area in which MDI windows are displayed.
menu .................... Provides popup-menus.
menubar ................. Provides pull-down menu items.
messagebox .............. Provides message boxes displaying informative messages and simple questions.
mimetype ................ Provides MIME type handling.
movie ................... Supports animated images.
networkdiskcache ........ Provides a disk cache for network resources.
networkinterface ........ Supports enumerating a host's IP addresses and network interfaces.
networkproxy ............ Provides network proxy support.
paint_debug ............. Enabled debugging painting with the environment variables QT_FLUSH_UPDATE and QT_FLUSH_PAINT.
pdf ..................... Provides a PDF backend for QPainter.
pepper-plugins .......... Enables use of Pepper Flash and Widevine plugins
picture ................. Supports recording and replaying QPainter commands.
printdialog ............. Provides a dialog widget for specifying printer configuration.
printer ................. Provides a printer backend of QPainter.
printing-and-pdf ........ Enables printing and output to PDF
printpreviewdialog ...... Provides a dialog for previewing and configuring page layouts for printer output.
printpreviewwidget ...... Provides a widget for previewing page layouts for printer output.
process ................. Supports external process invocation.
processenvironment ...... Provides a higher-level abstraction of environment variables.
progressbar ............. Supports presentation of operation progress.
progressdialog .......... Provides feedback on the progress of a slow operation.
properties .............. Supports scripting Qt-based applications.
proprietary-codecs ...... Enables the use of proprietary codecs such as h.264/h.265 and MP3
proxymodel .............. Supports processing of data passed between another model and a view.
pushbutton .............. Provides a command button.
qml-interpreter ......... Support for the QML interpreter
qml-network ............. Provides network transparency for QML
qml-profiler ............ The QML Profiler retrieves QML tracing data from an application.
quick-animatedimage ..... Provides the Qt Quick AnimatedImage Item
quick-canvas ............ Provides the Qt Quick Canvas Item
quick-designer .......... Provides support for the Qt Quick Designer in Qt Creator
quick-flipable .......... Provides the Qt Quick Flipable Item
quick-gridview .......... Provides the Qt Quick GridView item
quick-listview .......... Provides the Qt Quick ListView item
quick-particles ......... Provides a particle system for Qt Quick
quick-path .............. Provides Path elements in Qt Quick
quick-pathview .......... Provides the Qt Quick PathView item
quick-positioners ....... Provides Positioner items in Qt Quick
quick-shadereffect ...... Provides Shader effects in Qt Quick
quick-sprite ............ Provides the Qt Quick Sprite Item
quickcontrols2-material . Provides a Qt Quick Controls 2 style based on the Material Design guidelines
quickcontrols2-universal . Provides a Qt Quick Controls 2 style based on the Universal Design guidelines
quicktemplates2-hover ... Provides support for hover effects in Qt Quick Templates 2
radiobutton ............. Provides a radio button with a text label.
regularexpression ....... Provides an API to Perl-compatible regular expressions.
resizehandler ........... Provides an internal resize handler for dock widgets.
rubberband .............. Supports using rubberbands to indicate selections and boundaries.
scrollarea .............. Supports scrolling views onto widgets.
scrollbar ............... Provides scrollbars allowing the user access parts of a document that is larger than the widget used to display it.
scroller ................ Enables kinetic scrolling for any scrolling widget or graphics item.
sessionmanager .......... Provides an interface to the windowing system's session management.
settings ................ Provides persistent application settings.
sha3-fast ............... Optimizes SHA3 for speed instead of size.
sharedmemory ............ Provides access to a shared memory segment.
shortcut ................ Provides keyboard accelerators and shortcuts.
sizegrip ................ Provides corner-grips for resizing top-level windows.
slider .................. Provides sliders controlling a bounded value.
socks5 .................. Provides SOCKS5 support in QNetworkProxy.
sortfilterproxymodel .... Supports sorting and filtering of data passed between another model and a view.
spellchecker ............ Enables the use of Chromium's spellchecker
spinbox ................. Provides spin boxes handling integers and discrete sets of values.
splashscreen ............ Supports splash screens that can be shown during application startup.
splitter ................ Provides user controlled splitter widgets.
stackedwidget ........... Provides stacked widgets.
standarditemmodel ....... Provides a generic model for storing custom data.
statemachine ............ Provides hierarchical finite state machines.
statusbar ............... Supports presentation of status information.
statustip ............... Supports status tip functionality and events.
stringlistmodel ......... Provides a model that supplies strings to views.
style-stylesheet ........ Provides a widget style which is configurable via CSS.
syntaxhighlighter ....... Supports custom syntax highlighting.
systemsemaphore ......... Provides a general counting system semaphore.
systemtrayicon .......... Provides an icon for an application in the system tray.
tabbar .................. Provides tab bars, e.g., for use in tabbed dialogs.
tabletevent ............. Supports tablet events.
tableview ............... Provides a default model/view implementation of a table view.
tablewidget ............. Provides item-based table views.
tabwidget ............... Supports stacking tabbed widgets.
temporaryfile ........... Provides an I/O device that operates on temporary files.
textbrowser ............. Supports HTML document browsing.
textcodec ............... Supports conversions between text encodings.
textdate ................ Supports month and day names in dates.
textedit ................ Supports rich text editing.
texthtmlparser .......... Provides a parser for HTML.
textodfwriter ........... Provides an ODF writer.
timezone ................ Provides support for timezone handling.
toolbar ................. Provides movable panels containing a set of controls.
toolbox ................. Provides columns of tabbed widget items.
toolbutton .............. Provides quick-access buttons to commands and options.
tooltip ................. Supports presentation of tooltips.
topleveldomain .......... Provides support for extracting the top level domain from URLs.
translation ............. Supports translations using QObject::tr().
treeview ................ Provides a default model/view implementation of a tree view.
treewidget .............. Provides views using tree models.
udpsocket ............... Provides access to UDP sockets.
undocommand ............. Applies (redo or) undo of a single change in a document.
undogroup ............... Provides the ability to cluster QUndoCommands.
undostack ............... Provides the ability to (redo or) undo a list of changes in a document.
undoview ................ Provides a widget which shows the contents of an undo stack.
validator ............... Supports validation of input text.
webrtc .................. Enables WebRTC support
whatsthis ............... Supports displaying "What's this" help.
wheelevent .............. Supports wheel events.
widgettextcontrol ....... Provides text control functionality to other widgets.
wizard .................. Provides a framework for multi-page click-through dialogs.
xml-schema .............. Support for XML schema validation
xmlstream ............... Provides a simple streaming API for XML.
xmlstreamreader ......... Provides a well-formed XML parser with a simple streaming API.
xmlstreamwriter ......... Provides a XML writer with a simple streaming API.

Some of these features are public features which means that they change the official API of Qt. Compiling an application which uses a public feature that has been disabled will result in a compile error for the C++ side. The QML side requires more care and attention since properties which belong to a disabled feature will only be found at runtime. Private features are parts of Qt that are not directly exposed via an API. The removal of a private feature will typically only be found at runtime. The output of --list-features unfortunately doesn’t differentiate between public or private.

A feature can be disabled via configure with “-no-feature-. Features may have dependencies on other features defined. Disabling a single feature can therefore disable a whole set of dependent features. Example: “-no-feature-abstractslider” will also disable feature-filedialog (via slider → scrollbar → scrollarea → itemviews → listview → combobox). Dealing with these dependencies purely on the commandline takes quite a bit of knowledge about the internals of Qt and is a good reason for tooling support.

Note: ./configure will warn about conflicting -feature/-no-feature combinations, but will not tell about all implicitly disabled features in the configuration summary.

$ find . -name \*-config\*.h | grep -v include | xargs grep "\-1" | cut -d\  -f 2 | sort | sed s/QT_FEATURE/\-no\-feature/g | sed s/_/-/g

can give you a hint what features (including build dependencies which may have failed tests) you are missing in total.

How to create a minimal build?

Creating a minimal build is currently not for the faint of heart as Qt Lite is still evolving. Due to library dependencies detected on your build machine there might be build errors you have to deal with. There is also the issue that there are no CI builds available for Qt Lite configurations.

While Qt Lite is focused on Embedded Linux, we will do our experiment on a regular Linux Desktop (Ubuntu 16.04) for convenience. The knowledge gained can easily be transferred to an Embedded scenario like Buildroot or OpenEmbedded/Yocto.

To get started prepare a build setup as outlined here. Check out the qt5 git repo. You can set the HEAD to 40b07da1941a66a748c2 which is the commit ID we used when preparing this article (5.9 branch). We concentrate on essential modules and qtquickcontrols2.

 

nbsp;./init-repository –module-subset=qtbase,qtdeclarative,qtgraphicaleffects,qtquickcontrols,qtquickcontrols2,qtmultimedia
First configure a regular build. We pick a release build as it won’t stop because of warnings about unused variables or parameters. We also need to skip tools, tests and examples as these assume full Qt builds. Qt Lite is developed/tested without precompiled headers.

$ ./configure -opensource -release -no-compile-examples -no-pch -nomake tools -nomake tests

Next we will use ./configure and a bit of shell to create the input for our minimal build configuration.

$ ./configure -list-features 2>&1 | grep "\. " | while read f;do echo "-no-feature-`echo $f | cut -d\  -f 1`";done >>config.opt

Disabling the following features will currently break the build:

  • -feature-datestring
  • -feature-freetype
  • -feature-http
  • -feature-properties
  • -feature-temporaryfile
  • -feature-textdate
  • -feature-xmlstream
  • -feature-xmlstreamreader

This will change, but for now be sure to remove the respective -no-feature lines from config.opt before proceeding.

Also remove -no-feature-animation if Qt Quick is required and -no-feature-quick-shadereffect and -no-feature-quick-gridview for Qt Graphical Effects resp. Qt Quick Controls 2.

Likely your application will use plugins (eg for platform integration), so let’s also keep -feature-filesystemiterator and -feature-library.

Handy one-liner for all mentioned features above:

$ awk '!/datestring|filesystemiterator|freetype|http|library|properties|temporaryfile|textdate|xmlstream$|xmlstreamreader|animation|quick-gridview|shadereffect/' config.opt >config.stripped && mv config.stripped config.opt

Afterwards run

$ ./config.status && make && make install

The result will be a quite minimal build of Qt.

The following table shows what is currently possible (Qt 5.9 branch, 1st of May, release builds, x86_64, installed sizes, GCC 5.4.0). We also list results for Qt 5.8 to show the development trend.

Library
5.8 so
5.8 so min.
5.9 so
5.9 so min.
5.9 diff
libQt5Core 4.9MB 3.6MB 5.2MB (+) 3.4MB -35%
libQt5Gui 5.3MB 4.4MB 5.4MB 4.5MB -16%
libQt5Network 1.6MB 1.2MB 1.6MB 1.2MB -25%
libQt5PrintSupport 453KB 43KB 445KB 43KB -90%
libQt5Qml 4.1MB 3.8MB 4.0MB 3.9MB – 3%
libQt5Quick 4.3MB 2.9MB 4.4MB 3.3MB(*) -25%
libQt5Widgets 6.4MB 1.6MB 6.3MB 1.2MB -81%
libQt5Xml 232KB 123KB 236KB 123KB -48%

(*) With -feature-animation, otherwise Qt Quick is not built in 5.9
(+) Increase caused by inclusion of private pcre copy

 

This of course comes at a price: For a lot of applications such a minimal Qt will be useless due to missing functionality. So the list of removed features needs to be reviewed. And you might need to add things back if it turns out that they are required by the application. For a newly developed project this can be done in lock step with the development of the application itself. For an existing project it’s most likely not a good idea to start out with a minimal build. Here it makes more sense to look for big features that can be removed one by one without breaking the application.

For evaluation of static space savings we took basysKom’s QMLSDR (software defined radio) showcase. Its static binary size could be reduced from 27MB to 21MB (22% off) by using only the minimum required feature set (including settings, translations, quick-itemviews, quick-shadereffect and Qt Quick Templates).

Qt Lite 1 basysKom, HMI Dienstleistung, Qt, Cloud, Azure

Conclusion

The current state of Qt Lite shows its potential for reducing the size of Qt as well as the challenges ahead. Having unit tests for the Qt Lite subset would help to ensure that the resulting builds work as intended. Adding CI support would help to hunt down permutations of feature switches that don’t compile. Resolving dependencies without tool support takes knowledge about the internals of Qt. Consider what is available with Qt for Device Creation.

We are looking forward to a smaller Qt for embedded (and mobile) applications.

(This article has been written by Stephan and Frank)

Frank Meerkötter

Frank Meerkötter

Frank Meerkoetter is the Development Lead for basysKom GmbH, where he is consulting customers on industrial and embedded applications, often in combination with Qt. He is responsible for the technical consulting, system- and software-architecture within basysKom. He is the maintainer of Qt OPC UA and a contributor to the Qt project. He has a strong background in Embedded Linux, systems programming, distributed systems and application development. He holds a Master of Computer Science from the University of Applied Sciences in Darmstadt.

Leave a Reply

Your email address will not be published. Required fields are marked *