Thursday, 25 November 2010

Putting spaces in the name of a Qt for Symbian application

Just thought I'd share this solution for a problem that I came across, whilst writing a Qt app for Symbian devices.

The problem was that I was trying to give my app a name with spaces in, as it looks unprofessional having underscores or using CamelCase for the name that would appear below your application icon on a phone.
This cannot cimply be done by putting a name with spaces as the argument to the "TARGET = ..." line of your .pro file as Qt is not expecting this, nor does putting the name in quotation marks work.

The solution I used is from this bug report (whilst this blog entry doesn't really add much to the suggested work around in the bug report, i'm hoping that by writing it up in different words, someone may find the solution faster). As the bug report says, this problem is going to be fixed in Qt 4.7.2, but as of posting this you can only use Qt 4.6.3 to publish to Ovi Store so a workaround is currently required.

Firstly you should set the TARGET in your pro file to be a useful description without spaces but we are going to overwrite the application name everywhere it appears to the end user so it doesn't really matter what the TARGET name is.
Secondly you should add the following lines to the .pro file for your project:

customHeader.pkg_prerules = "$${LITERAL_HASH}{\"Your app name here\"},($$TARGET.UID3),$$replace(VERSION,"\.",",")"
DEPLOYMENT += customHeader

Replacing "Your app name here" with your app name but keeping the quotation marks as they are in the above code.
Secondly you should create a new file in your project directory with a name of your choosing, I call mine "forceName.loc" so it is clear what it's responsiblity is. Inside this file you should put the lines:

#define STRING_r_short_caption "Your app name"
#define STRING_r_caption "Your app name"
#define STRING_r_short_caption "Your app name"
#define STRING_r_caption "Your app name"

Again replacing "Your app name" with the appropriate text, leaving the quotation marks as they are.
Finally in order to get your application to use this file whilst building, you should add the following lines to your .pro file:

fix_loc.commands = $${_PRO_FILE_PWD_}/forceName.loc $${_PRO_FILE_PWD_}/$$basename(TARGET).loc
symbian-abld: fix_loc.commands = $$replace(fix_loc.commands,/,\\)
fix_loc.commands = $$QMAKE_COPY $$fix_loc.commands

where "forceName.loc" should be replaced by whatever name you used for the file and the rest should be left as it is.

I hope this manages to help someone.


  1. Guys check out The Nokia Qt SDK has ushered in a new era in mobile development for Symbian and Maemo , and forthcoming MeeGo devices from Nokia.
    With the Nokia Qt SDK, creating apps for hundreds of millions of Nokia device owners has never been easier or more rewarding.

    For details on all QT Tools and Downloads check the link:

  2. Hi there, awesome site. I thought the topics you posted on were very interesting. I tried to add your RSS to my feed reader and it a few. take a look at it, hopefully I can add you and follow.

    Symbian Application Development