Results 1 to 3 of 3

Thread: Reading from QFile when QTextStream is open

  1. #1
    Join Date
    Mar 2011
    Location
    PL
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Reading from QFile when QTextStream is open

    I use
    Qt Code:
    1. QTextStream in(stdin, QIODevice::ReadOnly)
    To copy to clipboard, switch view to plain text mode 
    To read text from standard input. But I need getChar() function to block execution until user press enter so i need to open
    Qt Code:
    1. file.open(stdin, QIODevice::ReadOnly);
    To copy to clipboard, switch view to plain text mode 
    Is this ok to call QFile::getChar when file is already open in QTextStream?

  2. #2
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Reading from QFile when QTextStream is open

    Why would you do that?

    You can use QTextStream to write chars into the file. See operator <<

  3. #3
    Join Date
    Mar 2011
    Location
    PL
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reading from QFile when QTextStream is open

    I want to read characters, not write.
    I need that because I want to block execution until user press enter. Something like this won't work
    Qt Code:
    1. QString temp;
    2. QTextStream in(stdin, QIODevice::ReadOnly);
    3. in >>temp;
    To copy to clipboard, switch view to plain text mode 
    if user press enter without pressing any other character before. So I need QFile::getChar()

Similar Threads

  1. QFile, QTextStream
    By Zergi in forum Newbie
    Replies: 1
    Last Post: 12th January 2008, 19:40
  2. QTextStream + QFile issue
    By trueneo in forum Qt Programming
    Replies: 3
    Last Post: 22nd September 2007, 15:16
  3. QFile, QTextStream, seek()
    By TheKedge in forum Qt Programming
    Replies: 4
    Last Post: 29th September 2006, 15:07
  4. Reading File using QFile and QTextStream
    By atm in forum Qt Programming
    Replies: 4
    Last Post: 13th July 2006, 23:12
  5. Qfile and QTextStream
    By sreedhar in forum Qt Programming
    Replies: 1
    Last Post: 28th June 2006, 10:43

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.