Results 1 to 5 of 5

Thread: QDataStream and flush()

  1. #1
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QDataStream and flush()

    Hi,

    I was wondering why QTextStream() has a flush() method, but QDataStream() doesnt.
    How do i flush a QDataStream()?
    And is there any way i can get the QFile* used by a QDataStream, or at least the filename of the file beign written to?

    thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QDataStream and flush()

    You could use QDataStream::device() and cast it to QFile I guess...

  3. #3
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDataStream and flush()

    yes, did`t see that. thanks.

    Still wired that QTextStream has flush() and QDataStream doesnt...

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QDataStream and flush()

    After a brief look at the sources: QTextStream buffers the content in a QString and at the end (or when calling flush()) it writes the content to the device. This is to take care of encodeing etc. QDataSream on the other hand directly writes to the device hence no flush() is needed.

  5. #5
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDataStream and flush()

    thanks for the answer!
    Will have a look at the sources myself next time.

Similar Threads

  1. QApplication::flush() doesn't work.
    By jthacker in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 28th June 2010, 11:36
  2. QTcpSocket sends data twice with flush()
    By xenome in forum Qt Programming
    Replies: 11
    Last Post: 2nd April 2010, 08:12
  3. How to flush a QPainter in Qt 4?
    By choucete in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2009, 11:18
  4. flush to file the QTreeview
    By rmagro in forum Qt Programming
    Replies: 0
    Last Post: 1st July 2009, 13:41
  5. flush draw events
    By rbp in forum Qt Programming
    Replies: 7
    Last Post: 19th March 2009, 09:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.