Results 1 to 2 of 2

Thread: QDatastream operate QPoint

  1. #1
    Join Date
    Nov 2016
    Posts
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QDatastream operate QPoint

    Hello, I wrote a nibble code to test QDatastream, and set one break point at line 7.
    Environment is Qt5, QtCreator.
    But in QtCreator, when the program stopped at Line 7, in Local and Expression view, the tmp value is (0, 0), supposed to be (6,11).

    Dont' know why tmp is not (6,11).

    Many thanks in advance.

    1, QPoint pos(6,11);
    2, QPoint tmp;
    3, QByteArray datagram;

    4, QDataStream out(&datagram, QIODevice::ReadWrite);
    //out.setVersion(QDataStream::Qt_4_3);

    5, out << pos;
    6, out >> tmp;
    7, return 0;

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QDatastream operate QPoint

    My guess is that the stream is "atEnd" when you write into it, so the >> operator creates a defalt QPoint since there is no data to read.

    You could add an "out.atEnd()" before line 6 to check if that theory holds.

    Cheers,
    _

Similar Threads

  1. Replies: 15
    Last Post: 18th September 2013, 15:03
  2. Replies: 3
    Last Post: 12th June 2012, 09:57
  3. QtScript QPoint
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 27th May 2009, 10:33
  4. Replies: 3
    Last Post: 24th April 2009, 23:41
  5. how to operate tcpsocket in thread again
    By succulent_lily in forum Qt Programming
    Replies: 3
    Last Post: 27th November 2008, 06:57

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.