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. QFile write doesn't write when data is too small.
Qt 6.11 is out! See what's new in the release blog

QFile write doesn't write when data is too small.

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 495 Views 2 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.
  • K Offline
    K Offline
    kayakaan02
    wrote on last edited by
    #1
    QFile myfqle1("C:\\here.txt");
    myfqle.open(QIODevice::WriteOnly);
    myfqle.write(data);
    

    Here's the code I use for opening and writing the file.
    When data.size() is smaller than approximately 16000 bytes, it just doesn't write the data to file.

    How can I solve this? thanks in advance.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      How do you determine that ?
      Until flushed or closed, your data might simply be sitting in a cash.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      K 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        How do you determine that ?
        Until flushed or closed, your data might simply be sitting in a cash.

        K Offline
        K Offline
        kayakaan02
        wrote on last edited by
        #3

        @SGaist I cannot flush because I don't use std::cout, also closing the file doesn't work.

        JonBJ 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          QFile has a flush method.

          You didn't answer my other question.

          On a side note, it's a good idea to do error checking. You might be trying to write to a read-only location.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • K kayakaan02

            @SGaist I cannot flush because I don't use std::cout, also closing the file doesn't work.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @kayakaan02 said in QFile write doesn't write when data is too small.:

            also closing the file doesn't work.

            I bet it does!

            1 Reply Last reply
            0

            • Login

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