Show the installed Qt and Qt Mobility version on Symbian and Maemo / MeeGo
Article Metadata
Code Example
Article
On the mobile platforms (Symbian and Maemo / MeeGo), Qt is installed only once on the system and all apps link to it dynamically. As a developer dealing with many different devices and Qt versions, it's often needed to quickly find out which Qt and Qt Mobility version is currently installed on a device. Use this QtVersionInfo tool to get a quick overview of the device environment.
Note that this example is built with Qt, so it only works on a device that already has Qt and Qt Mobility installed. Some Symbian^3 devices have Qt 4.6 pre-installed, but not the full Qt Mobility package, which is required to query the version information.
The example zip file therefore contains an installation package with the Smart Installer, which takes care of setting up Qt and Qt Mobility on the phone prior to installing the Qt Version Info tool (qtversioninfo_installer.sis). If you know that you already have Qt and Qt Mobility installed on the device, you can go for the non-Smart Installer package (qtversioninfo.sis).
Querying the Qt version
Getting the Qt version on a device requires Qt Mobility. The SystemInfo module has a method to get information about the Qt version, the device firmware version and the operating system. Qt Mobility 1.1 also adds a method to query the version of the Qt Mobility module. To make the tool as flexible as possible, it always queries the mobility version info with a fixed constant value. If the phone has an old mobility release installed and is not capable of returning the mobility version, the app will get an empty string back and therefore assume that it's running with a 1.0.x Qt Mobility release.
QSystemInfo si;
ui->versionQt->setText(si.version(QSystemInfo::QtCore));
// The Qt Mobility version can only be queried with Mobility 1.1+
#if (QTM_VERSION >= QTM_VERSION_CHECK(1, 1, 0))
// This is only executed when compiling with Mobility 1.1
// Doesn't relate to what is installed on the device, only the dev environment.
if (si.version(QSystemInfo::QtMobility).isEmpty())
{
// Libs installed on the device don't return the version -> has to be 1.0.x mobiltiy
ui->versionMobility->setText("1.0.x");
}
else
{
// Best situation: got the mobility version directly, so show it to the user
ui->versionMobility->setText(si.version(QSystemInfo::QtMobility));
}
#else
// Not most safe or elegant conversion, but works as the si.version returns
// an empty string if an unknown enum value is passed.
if (si.version((QSystemInfo::Version)4).isEmpty())
{
ui->versionMobility->setText("1.0.x");
}
else
{
// Compiling with Mobility 1.0 libs, but the phone has the new mobility version installed
ui->versionMobility->setText(si.version((QSystemInfo::Version)4));
}
#endif
ui->versionOS->setText(si.version(QSystemInfo::Os));
ui->versionFW->setText(si.version(QSystemInfo::Firmware));
Test application
Import the test app to your Qt Creator as part of the (Nokia) Qt SDK. The package also contains a pre-compiled .sis-file that you can directly install to your phone. File:QtVersionInfo.zip
A further developed example that prints even more information about the Qt installation can be downloaded from Nokia Developer Projects



1. You cannot not use capital letters in Maemo package names.
2. You must set 755 permission to debian/rules file.
-> Thanks a lot for reporting those two issues! Added those to my todo list, as I don't have time to go back to the app right now. If you have some time to spare to fix them, I would also appreciate if you could upload an updated version of the tool. In general, it's recommended to go for the newer and more powerful QtInfo info tool now released at: https://projects.developer.nokia.com/qtinfo/ (it's also linked at the bottom of the page)
3. And forcing 4 to QSystemInfo::Version is not going to work with Qt Mobility <= 1.1.
-> About this: true, but in that case the app will still output 1.0.x - so the app works, even though there is of course no more exact version estimation possible. The reason why I was forcing 4 to this value is that the call then works when the app is compiled with Qt 4.6/QtM1.0 (as in the Nokia Qt SDK 1.0) and the phone already has Qt Mobility >= 1.1 installed. So there was thought and testing put into that :)