QIODevice::bytesWritten ( qint64 bytes ) signal not working
-
As tobias Hunger has already suggested "bytesWritten":http://developer.qt.nokia.com/doc/qt-4.8/qiodevice.html#bytesWritten sais :
[quote]This signal is emitted every time a payload of data has been written to the device. [/quote]
you may use the "readyRead signal":http://developer.qt.nokia.com/doc/qt-4.8/qiodevice.html#readyRead and check the number of byte available with "bytesAvailable":http://developer.qt.nokia.com/doc/qt-4.8/qiodevice.html#bytesAvailable -
for of all thanx to all for spending ur precious time with my problem.
@ andre: the data is written into the device continously.
@volker: i want to replace readyRead() signal because, readyRead() signal gives me random amount of data i.e whenever this signal is emitted it doesn't always give me same amount of data.
So i wanted to replace it by bytesWritten() signal which will be emitted only when the specified amount of data is there in the IODevice.
@koahnig: if the problem is about the direction of data, then i have no other option than to stick with the readRead() signal... :(
thanx...
-
The data is written by whom? By your own application? In that case, you can use bytesWritten(). However, even in this case, the number of bytes written is out of your control. However, it seems that you're using readyRead() now, and that would mean that you are reading now.
I'm really not sure what you want to achieve... Why is it an issue that you don't get a constant number of bytes from readyRead?
-
basically what i want is, every time when i get this signal ( bytesWritten() or readyRead() ) , i want constatnt number of bytes to be available to read...
but this is not happening when i used readyRead(), thats why i was trying to use bytesWritten() signal, but even after using bytesWritten() signal, if i am not able to control the number of bytes then i think i have to use readyRead only, i have no other option...thanx andre...
-
No chance, with neither of the methods will give you such a guarantee. If you're reading, you cannot just use the bytesWritten signal because you think it suits your fancy. It just doesn't work that way.
For your actual issue, I would probably just:
ignore the signal if the number is lower than what I'd like, and
just read the wanted number of bytes if the number is equal or higher than what I'd like