Results 1 to 2 of 2

Thread: read input string --> text mode

  1. #1
    Join Date
    Nov 2006
    Posts
    96

    Default read input string --> text mode

    Hi, I want to read input from the user in text mode QT application and this doesn't stop the program to enter the name:

    Qt Code:
    1. QString enteredName;
    2. QFile inputFile,outputFile;
    3. cout << "Enter the name you want to search for: ";
    4. inputFile.open(stdin,QIODevice::ReadOnly);
    To copy to clipboard, switch view to plain text mode 

    I didn't add the line where I want to write the contents into enteredName...how can I do that?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: read input string --> text mode

    The following example is from QTextStream docs:
    Qt Code:
    1. QTextStream stream(stdin);
    2. QString line;
    3. do {
    4. line = stream.readLine();
    5. } while (!line.isNull());
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49

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.