Results 1 to 6 of 6

Thread: QDataStream and pointer

  1. #1
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default QDataStream and pointer

    Hi. how can i send data over QDataStream?

    a try this:

    QByteArray test;
    QtMobility::QGeoMapGroupObject *points = AddToMap();
    QDataStream ds(&test, QIODevice::WriteOnly);
    ds << points;

    but reading not woks

    QByteArray packet ....
    QtMobility::QGeoMapGroupObject *points = new QtMobility::QGeoMapGroupObject();
    QDataStream ds(&packet, QIODevice::ReadOnly);
    ds >> points;


    i have this error:

    error: no match for 'operator>>' in 'ds >> points'

  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 and pointer

    A pointer just points (hence the name) to the actual data.

    If this is a pointer to a list and the list has operators for QDataStream than you can derefernce before streaming.
    Otherwise iterate over whatever this is (an array?) and stream each element.
    You might want to first stream the length, so you can allocate the necessary structures before reading.

    Cheers,
    _

  3. #3
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QDataStream and pointer

    can you write me example how can i send this data?

  4. #4
    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 and pointer

    Well, the QGeoMapGroupObject is a QObject derived class, so it can't be easily serialized.

    What exactly is your goal?

    Cheers,
    _

  5. #5
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QDataStream and pointer

    in QtMobility::QGeoMapGroupObject i have some routes, pixmap and other things which i can add to map. but this is in plugin. And map is in mainwindow where is connected this plugin. I must send this created QtMobility::QGeoMapGroupObject into mainwindow for adding to map.

  6. #6
    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 and pointer

    Ah, within the same process.
    You don't need to serialize for that.

    The plugin host API could have a method that the plugin can call with the pointer or the plugin could emit the object via signal.

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 12th December 2013, 15:25
  2. Replies: 1
    Last Post: 4th December 2010, 18:20
  3. QDataStream use
    By Doug Broadwell in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2007, 23:17
  4. QDataStream, QTreeWidgetItem, pointer
    By baca in forum Qt Programming
    Replies: 6
    Last Post: 16th February 2007, 17:59
  5. QDataStream
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 23rd August 2006, 15:40

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.