Results 1 to 4 of 4

Thread: Get version from a rc file?

  1. #1
    Join Date
    Feb 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Get version from a rc file?

    Does anyone know how to get the version from an rc file? Or is there a better way to keep track of version within QT?

    When I used MFC I used 'GetModuleFileName' a win api I passed in an 'AfxGetInstanceHandle' which is an MFC call. I really don't want to keep MFC in my qt program.

    Thanks for any help!

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Get version from a rc file?

    I'm not sure how you mean. Do you want to get the version of the resource or the version of you application.

    If you saved the application's version as a string resource, you can use a const QString or a define just as well.

  3. #3
    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 Re: Get version from a rc file?

    rc files are fairly specific to Windows. ergo, I don't think Qt supports them. Qt has its own resource system to embed resources inside the executable, but is used mostly for storing individual files/graphics, not for plain strings - unless you want to store your string inside a separate file. Otherwise, storing version in a macro #define or const string is fairly typical (and more flexible/portable)
    Software Engineer



  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: Get version from a rc file?

    I tend to use a define in .pro file:

    # MMmmPP
    # MM = major, mm = minor, PP = patch
    DEFINES += MYAPP_VERSION=0x031201
    Qt Code:
    1. QString version = QString("%1.%2.%3")
    2. .arg((MYAPP_VERSION & 0xFF0000) >> 16, 2, 16, QChar('0'))
    3. .arg((MYAPP_VERSION & 0x00FF00) >> 8, 2, 16, QChar('0'))
    4. .arg((MYAPP_VERSION & 0x0000FF), 2, 16, QChar('0')); // "03.12.01"
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. Draging a non-existing file to the Windows Desktop
    By klaus1111 in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2007, 11:47
  2. SQLite-DB in a qrc file
    By Lykurg in forum Qt Programming
    Replies: 5
    Last Post: 31st July 2006, 19:24
  3. QHttp GET File & Password
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 11th June 2006, 13:04
  4. Accessing DTD in an XML file via QtXml module?
    By jorma in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2006, 18:09
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

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.