View Full Version : How to get Application Name like AfxGetAppName of MFC
rajeshs
26th September 2007, 07:50
Hi Friends,
If anybody knows how to get Application name in qt ? it's like AfxGetAppName( ) function of MFC , Please help me,
Thanks
Rajesh.S
jpn
26th September 2007, 08:39
Is it same than QCoreApplication::applicationFilePath()?
rajeshs
26th September 2007, 09:05
Thank you ,
This is returning App name with PAth,
I need only Appname,
Is it Possible,
Regards
Rajesh.S
jpn
26th September 2007, 10:09
So pick the file name with QFileInfo::fileName():
QString fileName = QFileInfo(QApplication::applicationFilePath()).fil eName();
wysota
26th September 2007, 11:47
Or directly:
QString name = QCoreApplication::arguments().at(0);
jpn
26th September 2007, 13:29
Or directly:
QString name = QCoreApplication::arguments().at(0);
What if the app is launched from a different dir? ;)
> path\to\app.exe
rajeshs
27th September 2007, 09:20
QString fileName = QFileInfo(QApplication::applicationFilePath()).fil eName();
Its Returning AppName.exe
From this i can get AppName,
It's very use ful reply Thank you for ur discussion and replies
jpn
27th September 2007, 09:33
Notice QFileInfo::baseName() also.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.