Solved QTextStream and transactions
-
Why does not QTextStream support transactions and, hence, the managment of fragmentation, as opposed to QDataStream?
-
QDataStream
only provides a convenient interface over the transaction, the actual transaction is handled by theQIODevice
directly: https://doc.qt.io/qt-5/qiodevice.html#startTransaction
You are free to use transactions withQTextStream
you just need a couple more lines of code.- instead of
dataStream.startTransaction()
you would usetextStream.device()->startTransaction();
- instead of
if(dataStream.commitTransaction()){/*do stuff*/}
you would use:
if(textStream.status() == QTextStream::Ok){ textStream.device()->commitTransaction(); /*do stuff*/ } else{ textStream.device()->rollbackTransaction(); }
- instead of