Results 1 to 2 of 2

Thread: applicationName ?

  1. #1
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default applicationName ?

    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?
    Software Engineer



  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: applicationName ?

    Quote Originally Posted by gfunk
    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 )
    Quote Originally Posted by gfunk
    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:
    Qt Code:
    1. QFileInfo info( QCoreApplication::instance()->applicationFilePath() );
    2. QString name( info.baseName() );
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to jacek for this useful post:

    gfunk (19th July 2006)

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.