Results 1 to 4 of 4

Thread: Serialization problem

  1. #1
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Serialization problem

    Hi everyone, I been given a task to serialize a QList of pointers to objects. The objects are of type "Film" with member variables "Film name", "Film ID", "Film Director" etc. The serializer object must display the above info in a file "myFile.txt" and I must also create another serializer to read the info from the file back into the QList as film objects. I've managed to to write the program except the function to read the data from the file back into the QList. I'm failing to get that function right. Any help will be appreciated.

  2. #2
    Join Date
    Jun 2010
    Location
    Pretoria, South Africa
    Posts
    22
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Serialization problem

    How are you writing the data to the file (i.e. in what format)? Are you using QDataStream?

  3. #3
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Serialization problem

    I am using QTextStream.


    Added after 19 minutes:


    If I can know how to read a text file word by word, my problem will be solved.
    Last edited by ayanda83; 23rd September 2012 at 17:44.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Serialization problem

    Quote Originally Posted by ayanda83 View Post
    If I can know how to read a text file word by word, my problem will be solved.
    Qt Code:
    1. QString word;
    2. while(!file.atEnd()) {
    3. stream >> word;
    4. doSomethingWith(word);
    5. }
    To copy to clipboard, switch view to plain text mode 
    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.


Similar Threads

  1. QSettings custom class serialization problem
    By sakya in forum Qt Programming
    Replies: 1
    Last Post: 19th December 2011, 11:00
  2. XML serialization into a X3D scene
    By sajis997 in forum Newbie
    Replies: 1
    Last Post: 30th August 2011, 10:57
  3. Serialization of QTextEdit
    By naghekyan in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2010, 06:02
  4. XML Serialization of Qt Objects
    By sasi in forum Qt Programming
    Replies: 1
    Last Post: 29th June 2009, 19:25
  5. Serialization
    By donmorr in forum Qt Programming
    Replies: 4
    Last Post: 16th November 2006, 13:51

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.