Results 1 to 4 of 4

Thread: QTextStream problem

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QTextStream problem

    Hi,

    I'm having problems with QTextStream

    Qt Code:
    1. bool b1 = m_qFile.isOpen(); //returns true
    2. m_qStream.setDevice(&m_qFile); //QTextStream
    3. m_qStream2.setDevice(&m_qFile); //QDataStream
    4.  
    5. QStringList qList = m_qText.split(QString(" "));
    6. QString qText;
    7. for (int i=0; i<qList .count(); i++)
    8. {
    9. qText= qList.at(i);
    10. m_qStream << qText; //It don't write anything
    11. m_qStream2 << qText; //It writes the QString
    12. }
    13. m_qFile.flush();
    14. m_qFile.close();
    To copy to clipboard, switch view to plain text mode 

    If I use QTextStrem, it don't write anything to the file but using QDataStream it writes the QString data into the file. I don't understand what it's happening.

    Thanks,
    Òscar Llarch i Galán

  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: QTextStream problem

    Could you provide a minimal compilable example that reproduces the problem?

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTextStream problem

    Hi,
    I don't understand what is happenning. I have made a simple example to get it to you and it works but in my application still not working.

    I'm using QTextStream and QDataStream into a QThread derivated class. I have another application that it works.

    Thanks,
    Attached Files Attached Files
    Òscar Llarch i Galán

  4. #4
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTextStream problem

    Hi,

    I have made another test. My code doesn't work if I insert it into a "switch-case" statment. I have removed "switch" statment and now it works.

    Thanks for replying,
    Òscar Llarch i Galán

Similar Threads

  1. Create QTextStream
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 17th June 2007, 20:25
  2. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15: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.