Results 1 to 13 of 13

Thread: show build date in about box

  1. #1
    Join Date
    Jul 2006
    Location
    Belgium
    Posts
    6
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default show build date in about box

    Hi,

    I have two questions :
    - How can i obtain the build date of an application ? I would like to show this in the about box.
    - Is there something like a build number that increments with every build ? I could show this in the about box too.

    Thanks for any suggestions.

    Cedric.

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

    Default Re: show build date in about box

    Quote Originally Posted by glocker50 View Post
    I have two questions :
    - How can i obtain the build date of an application ? I would like to show this in the about box.
    You can use qmake to define a macro with the current date or #include a file which defines such a macro.

    For example add such a line to your project file:

    DEFINES += "BUILDDATE=system(date -R)"

    And then in your app create a string containing the date:

    Qt Code:
    1. QString dat = QString::fromLocal8Bit(BUILDDATE);
    To copy to clipboard, switch view to plain text mode 

    - Is there something like a build number that increments with every build ? I could show this in the about box too.
    Not out of the box, but you can simulate it using qmake as well.

  3. #3
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: show build date in about box

    Didn't you forget the $$? I can't test it for linux right now but to make it work for winxp as well it should be:
    Qt Code:
    1. win32:DEFINES += BUILDDATE=$$system(date /t)
    To copy to clipboard, switch view to plain text mode 
    Last edited by spud; 16th January 2007 at 02:12. Reason: missing [code] tags

  4. #4
    Join Date
    May 2010
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: show build date in about box

    Why not just use the __DATE__ and __TIME__ defines. AFAIK they are available in gcc and whatever windows calls their compiler

  5. The following user says thank you to ndastur for this useful post:

    BrainB0ne (16th January 2012)

  6. #5
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: show build date in about box

    it is working fine i want in 12 hour format it is 24hour format how i can set.....

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

    Default Re: show build date in about box

    Pass the string to a parsing function and reformat the output the way you want. See QDateTime::fromString() and QDateTime::toString()
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: show build date in about box

    program compile time in 24 hour format .... should show in 12hour format
    send sample code it is usefull....

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

    Default Re: show build date in about box

    Quote Originally Posted by mouni View Post
    send sample code it is usefull....
    You forgot "please".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #9
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: show build date in about box

    it s nt possible


    Added after 1 6 minutes:


    anybody tell me how to set....
    Last edited by mouni; 30th April 2015 at 12:35.

  11. #10
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: show build date in about box

    Qt Code:
    1. int hoursIn12HourFormat = (hours > 12 ? hours - 12 : hours);
    To copy to clipboard, switch view to plain text mode 

    You're welcome.

    Edit: and here's something else for free:

    Qt Code:
    1. QString suffix = (hours > 12 ? "PM" : "AM");
    2. int hoursIn12HourFormat = (hours > 12 ? hours - 12 : hours);
    To copy to clipboard, switch view to plain text mode 
    Last edited by d_stranz; 30th April 2015 at 16:57.

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

    Default Re: show build date in about box

    LOL Really
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #12
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: show build date in about box

    i used __Time__ macro how can i declare to string ...

  14. #13
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: show build date in about box

    __TIME__

    It might be easier for you if you simply posted the requirements for whatever program you're trying to write and let us write it for you. Or maybe just learn how to write C++ programs before trying to write a C++ program.

Similar Threads

  1. Using qmake to build multiple apps and libs
    By marchand in forum Newbie
    Replies: 2
    Last Post: 12th June 2006, 17:33
  2. WYSIWYG html, Window show png icon mac no!
    By patrik08 in forum Qt Programming
    Replies: 10
    Last Post: 25th May 2006, 12:01
  3. QMAKE: Specifying Build Dependencies
    By JohnSuykerbuyk in forum Qt Programming
    Replies: 1
    Last Post: 5th May 2006, 09:46
  4. QtSingleApplication
    By mule in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2006, 19:21
  5. Working with Date type in database applications
    By kolach in forum Qt Programming
    Replies: 13
    Last Post: 25th January 2006, 14:20

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.