PDA

View Full Version : applicationName ?



gfunk
19th July 2006, 01:59
What's supposed to be the output of qApp->applicationName()? I run it for my app but all I get is an empty string. Is there an easy way to get the application name through Qt? The only way I see so far is qApp->arguments().at(0)
which gives me
c:\local\apptest\debug\AppTest.exe

Is there an easier Qt way to just get the "AppTest" out of this string?

jacek
19th July 2006, 02:05
What's supposed to be the output of qApp->applicationName()?
You have to set the applicationName property first:

applicationName : QString
This property holds the name of this application.
The value is used by the QSettings class when it is constructed using the empty constructor. This saves having to repeat this information each time a QSettings object is created.
Access functions:
QString applicationName ()
void setApplicationName ( const QString & application )


Is there an easy way to get the application name through Qt?
I would call it executable name, anyway you can use this to get it:
QFileInfo info( QCoreApplication::instance()->applicationFilePath() );
QString name( info.baseName() );