Results 1 to 8 of 8

Thread: How to get Application Name like AfxGetAppName of MFC

  1. #1
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up How to get Application Name like AfxGetAppName of MFC

    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
    Last edited by rajeshs; 26th September 2007 at 06:51. Reason: Title changed
    Thanks,
    Rajesh.S

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to get Application Name like AfxGetAppName of MFC

    J-P Nurmi

  3. #3
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get Application Name like AfxGetAppName of MFC

    Thank you ,
    This is returning App name with PAth,

    I need only Appname,

    Is it Possible,

    Regards
    Rajesh.S
    Thanks,
    Rajesh.S

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to get Application Name like AfxGetAppName of MFC

    So pick the file name with QFileInfo::fileName():
    Qt Code:
    1. QString fileName = QFileInfo(QApplication::applicationFilePath()).fileName();
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get Application Name like AfxGetAppName of MFC

    Or directly:
    Qt Code:
    1. QString name = QCoreApplication::arguments().at(0);
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to get Application Name like AfxGetAppName of MFC

    Quote Originally Posted by wysota View Post
    Or directly:
    Qt Code:
    1. QString name = QCoreApplication::arguments().at(0);
    To copy to clipboard, switch view to plain text mode 
    What if the app is launched from a different dir?
    > path\to\app.exe
    J-P Nurmi

  7. The following user says thank you to jpn for this useful post:

    rajeshs (27th September 2007)

  8. #7
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: How to get Application Name like AfxGetAppName of MFC

    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
    Thanks,
    Rajesh.S

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to get Application Name like AfxGetAppName of MFC

    Notice QFileInfo::baseName() also.
    J-P Nurmi

Similar Threads

  1. dll + application
    By fpujol in forum Qt Programming
    Replies: 11
    Last Post: 15th April 2007, 18:37
  2. Replies: 3
    Last Post: 8th December 2006, 18:51
  3. Gnome makes application crash
    By regix in forum Qt Programming
    Replies: 35
    Last Post: 18th August 2006, 19:44
  4. Replies: 3
    Last Post: 31st March 2006, 18:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.