Results 1 to 3 of 3

Thread: Compatibility of QDataStream btw. 32 and 64bit

  1. #1
    Join Date
    Feb 2009
    Posts
    79
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Compatibility of QDataStream btw. 32 and 64bit

    I have written an application using Qt 4.5.2 a few years ago.

    Now I wanted to port that code to the latest version of Qt (4.7.4),
    and did not think further about the fact that I am now using a 64 bit OS (Mac OS X Lion).

    Now I ran into trouble with my serialization routines which all rely on QDataStream.

    The problem is that I did not use the qreal, qint32, qint64.... types in my sources,
    and just declared int's and float's.

    Is it enough to use the QDataStream::setVersion(Qt::Qt_4_5)?
    Is Qt aware of serializing an int under 32bit in the same way as under 64bit?

    Thanks for your help in advance!
    olidem

  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: Compatibility of QDataStream btw. 32 and 64bit

    Note, there are no operators for serializing "int", only qint32, qint64, etc. So your ints are in fact treated as they had a defined length (e.g. int is equal to qint32 on 32bit machines). Thus if you store an int on 32 bit machine, you will store it as qint32, so you have to read it back as qint32. Setting the version of Qt will not change anything.
    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.


  3. #3
    Join Date
    Feb 2009
    Posts
    79
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Compatibility of QDataStream btw. 32 and 64bit

    So, this means that you're lost in case you used standard int's and float's ...?

    On the other hand, if we assume char's are 1 byte in every architecture,
    then
    Qt Code:
    1. QVector<char> vec;
    2. vec << 'a' << 'b';
    3. d << vec;
    To copy to clipboard, switch view to plain text mode 
    then the latter code would be 'protable' and do the same on every architecure?
    (I have the length of the vector in mind...it will be transmitted in an unambiguous way, right?)

Similar Threads

  1. Building 64bit Shared Qt Dlls on 64bit Win7 for Visual Studio
    By HarrySatt in forum Installation and Deployment
    Replies: 1
    Last Post: 29th November 2011, 04:39
  2. Replies: 4
    Last Post: 12th May 2011, 10:06
  3. 64 bit compatibility
    By johnmauer in forum Qt Programming
    Replies: 4
    Last Post: 25th December 2009, 13:28
  4. QtDesigner compatibility
    By lixo1 in forum Qt Tools
    Replies: 2
    Last Post: 11th February 2009, 11:50
  5. VTK and QT compatibility
    By nasty81 in forum Qt Programming
    Replies: 1
    Last Post: 11th April 2008, 12:32

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.