The write function is defined in the QIODevice class. It should, according to the documentation, return the number of bytes written. But, instead of the number of bytes, it returns the number of bytes not written!
The contents of the write function are shown below
QCoro::Task<qint64> QCoroIODevice::write(const QByteArray &buffer) {
auto bytesWritten = mDevice->write(buffer);
while (bytesWritten > 0) {
const auto flushed = co_await waitForBytesWritten(-1);
bytesWritten -= flushed.value();
}
co_return bytesWritten;
}
As you can see, the number of bytes is constantly decreasing and if successful, the result of the function will be 0.
This is definitely not the number of bytes written.
The write function is defined in the QIODevice class. It should, according to the documentation, return the number of bytes written. But, instead of the number of bytes, it returns the number of bytes not written! The contents of the write function are shown below
As you can see, the number of bytes is constantly decreasing and if successful, the result of the function will be 0. This is definitely not the number of bytes written.