Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. File errors in Ubuntu
Forum Updated to NodeBB v4.3 + New Features

File errors in Ubuntu

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 3.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mythbusterma
    wrote on 8 Oct 2011, 04:13 last edited by
    #1

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

    @openFileT1.setFileName(lastName.append(".comp"));
    openFileT2.setFileName(lastName.append(".k"));
    openFileT1.open(QFile::ReadWrite);
    openFileT2.open(QFile::ReadWrite);
    fileStream.setDevice(&openFileT1);
    serialStream.setDevice(&openFileT2);
    if (!openFileT2.isOpen() || !openFileT2.isWritable()) {
    return NULL;

    }
    openFileT1.write("test");
    
    debugPrint(openFileT1.errorString());
    
    serialStream << QString("0xN0500576");
    

    @

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

    @QDir::setCurrent("/home/XXXX/");@

    before that

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

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on 8 Oct 2011, 18:59 last edited by
      #2

      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?

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mythbusterma
        wrote on 8 Oct 2011, 19:24 last edited by
        #3
        • /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 :)

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on 8 Oct 2011, 21:09 last edited by
          #4

          OK please provide a small example we can try then.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mythbusterma
            wrote on 10 Oct 2011, 22:22 last edited by
            #5

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

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fluca1978
              wrote on 11 Oct 2011, 07:22 last edited by
              #6

              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.

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                ZapB
                wrote on 11 Oct 2011, 10:33 last edited by
                #7

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

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mythbusterma
                  wrote on 11 Oct 2011, 19:24 last edited by
                  #8

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

                  1 Reply Last reply
                  0

                  3/8

                  8 Oct 2011, 19:24

                  topic:navigator.unread, 5
                  • Login

                  • Login or register to search.
                  3 out of 8
                  • First post
                    3/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved