Results 1 to 6 of 6

Thread: How to add the auto-"build number" in Qt Application?

  1. #1
    Join Date
    Oct 2011
    Posts
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default How to add the auto-"build number" in Qt Application?

    Hi All,

    currently i am using follwoing code to reprasent SW version .
    ---------------
    #define MajorNumber 11
    #define MinorNumber 22
    #define ReleaseNumber 33
    #define BuildNumber 44
    ------------
    Problem here is ,each and every time manualy changing these macro values(build number) to update the SW Version.

    1)Is there anyway options in Qt, to auto update the build number in SW Version ?
    In other worlds ,How to add the auto-"build number" in Qt Application?

    Please guide me on the same.

    Regards,
    sambu.

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to add the auto-"build number" in Qt Application?

    One option would be to stick that define in separate file, then create a custom build step which would run a shell script (or your own command line tool) that incrementes the build number before the actual build takes place.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to add the auto-"build number" in Qt Application?

    Maybe [WIKI]Version_numbering_using_QMake[/WIKI] can help you.

  4. #4
    Join Date
    Oct 2011
    Posts
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to add the auto-"build number" in Qt Application?

    Hi Lykurg,

    thanks for your replay.

    Here ,i could not get any the Auto build number. i think,this is also similar to macro. here they declar a string in .pro file and reading the string in main.cpp file ,to print the version.
    here ,if we build the application second time also same string will dispaly.
    there is no provision for store the old version number.

    can u sugest any onther way or can u provide any sample code ?

    -----------------------
    from :Version_numbering_using_QMake:

    You can have automatic version numbering for libraries built using QMake. Consider the following example using SVN to get the current version (substitute it with a command that returns the version number for your project).

    Add the following to your project file:

    VERSION = $$system(svn info -r HEAD . | grep 'Changed\ Rev' | cut -b 19-)
    !isEmpty(VERSION){
    VERSION = 0.$${VERSION}
    }You can also set a version for your application by adding:

    VERSTR = '\\"$${VERSION}\\"' # place quotes around the version string.
    DEFINES += VER=\"$${VERSTR}\" # create a VER macro containing the version stringThen you can use the "VER" macro in your application to obtain the quoted version number:

    #include <QtGui/QApplication>
    #include<QDebug>
    #include "application.h"

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    qDebug("VERSION: %s :\n", VER);
    return a.exec();
    }
    -------------------------

    regards.
    Sambu.


    Added after 45 minutes:


    Hi Spitefire,

    Thanks for nice idea.

    but how can we know before comple the application build process , whether it is build successful or fail to build ?
    can you send any sample snipets for the same,if you have.

    Regards,
    Sambu.
    Last edited by Sambu; 8th December 2011 at 13:38.

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to add the auto-"build number" in Qt Application?

    Maybe I don't get you but
    Qt Code:
    1. VERSION = $$system(svn info -r HEAD . | grep 'Changed\ Rev' | cut -b 19-)
    To copy to clipboard, switch view to plain text mode 
    is querying dynamically the actual version from svn. You can alter that easily if you work with git or others.

  6. #6
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to add the auto-"build number" in Qt Application?

    Depends on where you want to implement it you need different approach.

    If it's for automatic build system then Lykrug's idea is better.

    But if it's for you to change the build number as you progress between commits to vcs, then you'll need to go with my suggestion (or something similar).

    As to the failed builds - I wouldn't bother with that, as long as every build has a different number it shouldn't be a problem if it fails or not.

Similar Threads

  1. Qt Creator Qt SDK, Remote Compiler "Build Failed: Errors in build"
    By strahlex in forum Qt Tools
    Replies: 0
    Last Post: 10th August 2011, 16:59
  2. QPlainTextEdit - "real" column number
    By Carlsberg in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2009, 11:53
  3. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  4. Vectors & auto-"delete"
    By Darhuuk in forum General Programming
    Replies: 5
    Last Post: 11th January 2008, 11:24
  5. Program error : [9;0] [?1cCreating mouse "Auto"
    By Cyrus in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 12th October 2006, 15:22

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.