Results 1 to 2 of 2

Thread: QFile::writeBlock: File not open

  1. #1
    Join Date
    May 2006
    Location
    Pune,India
    Posts
    63
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Unhappy QFile::writeBlock: File not open

    I made a dialog which takes, which two files as argument first one is source file nad second is destination file to copy first file.

    Qt Code:
    1. void mainForm::copy()
    2. {
    3. QFile src1 (le_src->text() );
    4. QFile dest (le_dest->text() );
    5. if(!src1.open(IO_ReadOnly) || !dest.open(IO_WriteOnly))
    6. return;
    7. else
    8. qDebug("Files opened.");
    9.  
    10. int len = src1.size()/1024;
    11. progress->setTotalSteps(len);
    12. progress->show();
    13. char *ch;
    14. while(!src.atEnd())
    15. {
    16. //ch = src.getch();
    17. src1.readBlock(ch, Q_ULONG(1042));
    18. //dest.putch(ch);
    19. dest.writeBlock (ch, Q_ULONG(1042));
    20. progress->setProgress(progress->progress()+1);
    21. //qApp->processEvents();
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 

    When I run this code following out put shows
    Files opened.
    QFile::writeBlock: File not open
    Segmentation fault

    I didn't understand what is wrong with this code.
    Last edited by wysota; 17th September 2006 at 23:15. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFile::writeBlock: File not open

    You don't create a buffer for data and pass uninitialized pointer to readBlock() and writeBlock().

Similar Threads

  1. SQLite-DB in a qrc file
    By Lykurg in forum Qt Programming
    Replies: 5
    Last Post: 31st July 2006, 19:24
  2. how to run qtopia
    By freegnu in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 1st July 2006, 15:31
  3. QProcess open all file -> url.dll,FileProtocolHandler
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2006, 17:07
  4. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

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.