Results 1 to 13 of 13

Thread: QTList Custom class Serlization

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QTList Custom class Serlization

    Huh Nowhere in this thread have you done anything like that.
    Your code:
    Qt Code:
    1. QList<CustomClass*> list;
    2. QDataStream out(&file);
    3. out <<list; //works fine
    To copy to clipboard, switch view to plain text mode 

    My code:
    Qt Code:
    1. QList<CustomClass*> list;
    2. QDataStream out(&file);
    3. out << list.size();
    4. foreach(CustomClass* p, list)
    5. out << *p;
    To copy to clipboard, switch view to plain text mode 

    Wysota's prompting would give you something that would make your code work.
    My code gives you another way to do it using the operator<<() for CustomClass that you already have.

  2. The following user says thank you to ChrisW67 for this useful post:

    saravanadel (25th January 2012)

Similar Threads

  1. Replies: 7
    Last Post: 18th August 2011, 14:43
  2. Using custom class as a key (QSet)
    By daujeroti in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2011, 20:39
  3. qhash with custom class
    By dognzhe in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2009, 06:30
  4. custom class for tslib
    By nrabara in forum Newbie
    Replies: 1
    Last Post: 28th April 2009, 13:15
  5. Custom Model Class
    By mattjgalloway in forum Qt Programming
    Replies: 12
    Last Post: 4th June 2007, 17:30

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.