Results 1 to 14 of 14

Thread: Converting VC++ qreal to QDate

  1. #1
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Converting VC++ qreal to QDate

    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.

  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: Converting VC++ qreal to QDate

    What does the qreal hold?

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

  3. The following user says thank you to wysota for this useful post:

    Krish_ng (21st December 2007)

  4. #3
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Converting VC++ qreal to QDate

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

  5. #4
    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: Converting VC++ qreal to QDate

    Quote Originally Posted by Krish_ng View Post
    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.

  6. #5
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QDate to real

    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.

  7. #6
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QDate to real

    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

  8. #7
    Join Date
    Dec 2007
    Posts
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Converting qreal to QDate and vice-versa

    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

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Converting VC++ qreal to QDate

    { A bunch of threads merged. }

    Now keep the problem in this thread, thank you.
    J-P Nurmi

  10. #9
    Join Date
    Dec 2007
    Posts
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Converting VC++ qreal to QDate

    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.

  11. #10
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Converting VC++ qreal to QDate

    You have to find out what this double value means - neither Qt nor we know this. It depends on how the qreal is interpreted!

  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: Converting VC++ qreal to QDate

    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.

  13. #12
    Join Date
    Dec 2007
    Posts
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Converting VC++ qreal to QDate

    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

  14. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Converting VC++ qreal to QDate

    Quote Originally Posted by sashishk View Post
    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.

  15. #14
    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: Converting VC++ qreal to QDate

    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

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.