PDA

View Full Version : show build date in about box



glocker50
14th January 2007, 18:00
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.

wysota
14th January 2007, 19:52
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:


QString dat = QString::fromLocal8Bit(BUILDDATE);


- 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.

spud
16th January 2007, 02:11
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:

win32:DEFINES += BUILDDATE=$$system(date /t)

ndastur
3rd May 2010, 18:30
Why not just use the __DATE__ and __TIME__ defines. AFAIK they are available in gcc and whatever windows calls their compiler

mouni
30th April 2015, 10:25
it is working fine i want in 12 hour format it is 24hour format how i can set.....

wysota
30th April 2015, 10:32
Pass the string to a parsing function and reformat the output the way you want. See QDateTime::fromString() and QDateTime::toString()

mouni
30th April 2015, 10:38
program compile time in 24 hour format .... should show in 12hour format
send sample code it is usefull....

wysota
30th April 2015, 10:41
send sample code it is usefull....

You forgot "please".

mouni
30th April 2015, 12:35
it s nt possible

Added after 1 6 minutes:

anybody tell me how to set....

d_stranz
30th April 2015, 15:53
int hoursIn12HourFormat = (hours > 12 ? hours - 12 : hours);


You're welcome.

Edit: and here's something else for free:



QString suffix = (hours > 12 ? "PM" : "AM");
int hoursIn12HourFormat = (hours > 12 ? hours - 12 : hours);

wysota
2nd May 2015, 01:47
LOL :) Really :)

mouni
2nd May 2015, 08:42
i used __Time__ macro how can i declare to string ...

d_stranz
3rd May 2015, 22:14
__TIME__ (http://www.cprogramming.com/reference/preprocessor/__TIME__.html)

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.