File errors in Ubuntu

  • I'm using Ubuntu 11.04 (this problem has persisted since 10.04) and trying to write to a file as follows

    if (!openFileT2.isOpen() || !openFileT2.isWritable()) {
    return NULL;

    serialStream << QString("0xN0500576");


    where lastName is a valid string (I checked) and with the directory being declared


    before that

    Every time I run this, my debug console says the error is "Unknown Error", does anyone know what might be causing this?

  • Please post a small compilable example that reproduces the problem. Some things to check:

    • does /home/XXXX/ exist and do you have write-permissions to that directory?
    • what do the two calls to open() return?
    • what types are fileStream and serialStream?
    • why are you apparently attaching a stream on your QFile object and then calling write() directly on the QFile object?

    • /home/XXXX/ is a valid directory, and even when run as root I run into the same problem
    • They return true
    • fileStream is a QTextStream and serialStream is a QDataStream (according to the debugger both objects are valid during runtime)
    • This was a byproduct of my attempts at fixing it, I tried to see whether writing to the file directly would fix the problem, it doesn't

    Thanks for viewing my post :)

  • OK please provide a small example we can try then.

  • When I go and look at the file, the file has been created and has the correct name, but it's completely empty.

  • This is just a guess...maybe the file is empty because you did not close/flush it. And you are displaying an error string always, even I didn't find any reference on errorstring returning an empty string if no error has happened, so maybe the print is normal.

  • Again, please post a small example that shows the problem...then we can help you.

  • Ahhhh....many thanks, the flushing/closing did the trick, many thanks fluca.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.