PDA

View Full Version : Converting VC++ qreal to QDate



Krish_ng
17th December 2007, 04:34
I hav a qreal number which i need to convert to QDate.We are porting VC++ code to Linux.Is ther any way to convert qreal to QDate.In VC++ the CDate wil take qreal and gives Date .But QDate of Qt wont take qreal.

wysota
17th December 2007, 09:11
What does the qreal hold?

BTW. There is no such thing as "VC++". CDate is an MFC class.

Krish_ng
21st December 2007, 04:26
U r right...There is no qreal in VC++ .. we are poting our VC++ application to Linux using Qt ..v are replacing DATE(typedef double) of VC++ to qreal..In VC++ CDATE wil take DATE in constructor and give required date..But QDate has no such option...Is ther any way do to this..Any Ideas??

wysota
21st December 2007, 08:54
U r right...There is no qreal in VC++
No, I meant there is nothing you could call "Visual C++".


.. we are poting our VC++ application to Linux using Qt ..v are replacing DATE(typedef double) of VC++ to qreal..In VC++ CDATE wil take DATE in constructor and give required date..But QDate has no such option...Is ther any way do to this..Any Ideas??

But what do you keep inside that double?

Please don't port your code line by line, it doesn't make sense.

phillip_Qt
9th January 2008, 06:13
Hi All
Can any body help me?
I need convert QDate to real. but unfortunatly Qt doesnt provied this. and normal c++ tpe castings (static_cast, reinterpret_cast) r not working.
Can any body help me?

thank you all.

Gopala Krishna
9th January 2008, 07:07
May be you get int instead of real by using QDate::toJulianDay() which returns the julian (http://en.wikipedia.org/wiki/Julian_day)correpondant.

sashishk
10th January 2008, 14:28
Hi,

I'm working on a migration project from Windows to QT. The windows has DATE which is typedef of double. How do I convert a qreal/double to QDate and vice-versa?

Thanks in advance,
Aks

jpn
10th January 2008, 14:54
{ A bunch of threads merged. }

Now keep the problem in this thread, thank you.

sashishk
11th January 2008, 05:43
Its not like porting line by line. Ok, let me explain the scenario..............

I've a binary file which contains the date/time data stored as double at some specified location. Now I have to print that data into human readable form like Jan 20, 2008 08:30:30 something like that.

Now the steps followed in VC++ code:
1) Read the double value
2) Pass it to COleDateTime
3) Retrieve day, month, year

Now how do I retrieve the same using QT. The format of binary file can't be changed. So our input data is double only and we want to retrieve day/month/year as was done previously.

ChristianEhrlicher
11th January 2008, 07:51
You have to find out what this double value means - neither Qt nor we know this. It depends on how the qreal is interpreted!

wysota
11th January 2008, 11:43
If you know what the double represents you can convert it to a more sane format, like a timestamp or something like that. But if there is no function that would do it for you, you have to do it manually.

sashishk
12th January 2008, 07:14
I don't have any idea as to how we can store a particular date/time in double. Can you please provide me any pointers or article or code snippet, it would be of much help to me.

Thanks

jacek
12th January 2008, 15:30
I don't have any idea as to how we can store a particular date/time in double.
You just have to count the number of days that have passed since certain date.

wysota
12th January 2008, 20:23
I'm afraid we don't have an idea too. I can point you to MSDN to look for the function you mentioned in hope there will be a broader explanation there.