Results 1 to 6 of 6

Thread: Accessing version resources from inside the app

  1. #1
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Accessing version resources from inside the app

    Hi!

    Both Mac and Windows have application version information, which can be accessed thru "Info" on Mac and "Properties" on Win32, useful stuff especially when you want to make an intelligent installer.

    Is it possible to access these version resources from inside the code in a Qt way, e.g. to display the version in the application "About" box?

    Or is there some other way to simplify the application version management?


    BN
    Last edited by bnilsson; 26th February 2010 at 22:19.
    MacOSX user dabbling with Linux and Windows.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Accessing version resources from inside the app

    There are several ways, but I don't think Qt can access Windows resources directly yet (Which the version resource is stored as), so you would have to parse the exe file yourself. An easier alternative (which also gives greater flexibility, but will not show up under Properties) would be to insert your own version information into a unique token in the file (eg. a structure starting with the string "$$VER_INFO$$" for example). For an installer, I'd probably use the later, and just use the former for the human readable part.

  3. #3
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing version resources from inside the app

    Ok.

    Is there any native way to access the version resource? I guess there must be.

    (Throughout my history of programming, I have always done cross-platform, so I am not good at neither windows or Mac native...)

    The most urgent for me would be to get this working in Windows, Mac may wait.
    MacOSX user dabbling with Linux and Windows.

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Accessing version resources from inside the app

    Sure, under Windows, you can use FindResource, LoadResource, LockResource.

    If you want an installer to check the version of a file, try GetFileVersionInfo()

  5. #5
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing version resources from inside the app

    I could not get FindResource etc. to work since I non't understand the terminology involved, not being a Windows man.
    So I decided to use GetFileVersionInfo() with the input file parameter from QCoreApplication::applicationFilePath ().
    I guess a bit more bulky, but at least I understand it and it works.

    BN
    MacOSX user dabbling with Linux and Windows.

  6. #6
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing version resources from inside the app

    Sorry, forgot to say thanks.
    The issue is solved and closed,

    Regards

    BN
    MacOSX user dabbling with Linux and Windows.

Similar Threads

  1. Is it possible to add QT resources to a DLL?
    By cboles in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2017, 00:12
  2. Creating an evaluation version or trial version
    By munna in forum General Discussion
    Replies: 9
    Last Post: 20th June 2015, 01:50
  3. Replies: 0
    Last Post: 11th August 2009, 09:38
  4. Replies: 5
    Last Post: 5th October 2008, 05:12
  5. Qt Resources
    By kaushal_gaurav in forum Qt Programming
    Replies: 3
    Last Post: 3rd October 2008, 16:30

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.