Results 1 to 2 of 2

Thread: QFile resized files gets truncated after writing

  1. #1
    Join Date
    May 2008
    Posts
    15
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QFile resized files gets truncated after writing

    Hi ppl,

    I wrote some code to generate a file with a specific size, in which I later put QByteArrays at specific positions (random-acces).
    Qt Code:
    1. ...
    2. file.resize(1024000);
    3. ...
    4. file.seek(12335);
    5. pos = file.pos();
    6. c_size=file.write(ba);
    7. pos2 = file.pos();
    8. file.close();
    9. ...
    10. //QT4.3 / mingw / windows xp
    To copy to clipboard, switch view to plain text mode 

    the initial QFile::resize works
    pos and pos2 indicate the right position

    after closing the file it is truncated

    Any help/idea is highly appreciated, after having exhausted my resources.
    Thanks in advance

  2. #2
    Join Date
    May 2008
    Posts
    15
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Solved

    I solved the problem:

    instead of
    Qt Code:
    1. file.open(QIODevice::WriteOnly)
    To copy to clipboard, switch view to plain text mode 
    I have to use
    Qt Code:
    1. file.open(QIODevice::WriteOnly | QIODevice::ReadOnly)
    To copy to clipboard, switch view to plain text mode 
    to avoid the truncation

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.