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. QTextStream and transactions

QTextStream and transactions

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 396 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.
  • T Offline
    T Offline
    tungsteno
    wrote on last edited by
    #1

    Why does not QTextStream support transactions and, hence, the managment of fragmentation, as opposed to QDataStream?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      QDataStream only provides a convenient interface over the transaction, the actual transaction is handled by the QIODevice directly: https://doc.qt.io/qt-5/qiodevice.html#startTransaction
      You are free to use transactions with QTextStream you just need a couple more lines of code.

      • instead of dataStream.startTransaction() you would use textStream.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();
      }
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      7

      • Login

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