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.
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.
What does the qreal hold?
BTW. There is no such thing as "VC++". CDate is an MFC class.
Krish_ng (21st December 2007)
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??
No, I meant there is nothing you could call "Visual C++".
But what do you keep inside that double?.. 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??
Please don't port your code line by line, it doesn't make sense.
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.
Cheers,
Phillip
--- Please post the solution you got to solve your problem. It may help others.
May be you get int instead of real by using QDate::toJulianDay() which returns the julian correpondant.
The biggest difference between time and space is that you can't reuse time.
-- Merrick Furst
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
{ A bunch of threads merged. }
Now keep the problem in this thread, thank you.
J-P Nurmi
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.
You have to find out what this double value means - neither Qt nor we know this. It depends on how the qreal is interpreted!
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.
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
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.
Bookmarks