Results 1 to 9 of 9

Thread: Where's my wrong?(Related to QFile & QTextStream)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 21 Times in 21 Posts

    Default Re: Where's my wrong?

    I think there's a line of code missing...
    Your "in" object is a QTextStream, right ?

    You have to link it to your file like this

    QTextStream in(&file);

    This must be done after your "file.open()" test.

    EDIT :
    OK, you corrected...
    You don't need to use a QTextStream by the way, you can do this directly :

    QString configFileContent = file.readAll();

    Guilugi.

  2. #2
    Join Date
    Mar 2007
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: Where's my wrong?

    I've tried both methods (QFile's readAll() and QTextStream's readAll() ) but i cannot get the content of the files. But I know that there is some lines in the file.. Cannot find the mistake

  3. #3
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 21 Times in 21 Posts

    Default Re: Where's my wrong?(Related to QFile & QTextStream)

    If you output the result of file.size(), is it null ?
    Maybe Qt can't open it (bad permissions, wrong path...) ?

  4. #4
    Join Date
    Mar 2007
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: Where's my wrong?(Related to QFile & QTextStream)

    Quote Originally Posted by guilugi View Post
    If you output the result of file.size(), is it null ?
    Maybe Qt can't open it (bad permissions, wrong path...) ?
    I logged in as Administrator on Windows XP, and there's no file permission problem. Also if there is permission problem, than i couldnt write on these files. But i can (it doesnt search but it appends. very strange)

    Qt Code:
    1. qint64 fileSize = file.size(); // 3651
    2. QString configFileContent = file.readAll(); // 0
    3. int configFileSize = configFileContent.count(); // 0
    To copy to clipboard, switch view to plain text mode 

    What do you think now?

Similar Threads

  1. Replies: 7
    Last Post: 17th July 2009, 09:40
  2. What's wrong with my actions???
    By fullmetalcoder in forum Qt Programming
    Replies: 6
    Last Post: 4th March 2007, 18:49
  3. Qt renders wrong font
    By durbrak in forum Qt Programming
    Replies: 8
    Last Post: 2nd November 2006, 14:36
  4. QListWidget...what's wrong
    By nupul in forum Newbie
    Replies: 16
    Last Post: 4th April 2006, 12:17
  5. Help please - what am I doing wrong?
    By Jimmy2775 in forum Qt Programming
    Replies: 6
    Last Post: 6th March 2006, 22:06

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.