Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator 2.4.1 console input

QtCreator 2.4.1 console input

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 3 Posters 6.8k 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.
  • B Offline
    B Offline
    belamoor
    wrote on last edited by
    #1

    I'm somewhat new and C++ and just starting with Qt. Trying to run a very simple program in QtCreator, which uses console input on WinXP:
    @#include <QString>
    #include <QTextStream>
    QTextStream cout(stdout);
    QTextStream cin(stdin);

    int main() {
    QString s2;
    cout << "Enter a sentence: ";
    s2 = cin.readLine();
    cout << "Here is your sentence:" << s2 << endl;
    cout << "The length of your sentence is: " << s2.length() << endl;
    return 0;
    }@

    But QTCreator's application output doesn't seem to allow typing in things. I've tried checking "Run in terminal" in Projects>Desktop>Run and the terminal shows up, but it seems kind of detached.It only contains "Press RETURN to close this window..." string printed and doesn't seem to interact with the program anyhow. Thanks in advance.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VanDerSam
      wrote on last edited by
      #2

      After operator
      @cout << "Enter a sentence: ";@

      you must insert operator

      @cout.flush();@

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chaos6
        wrote on last edited by
        #3

        Than You VanDerSam

        http://smashcs.wordpress.com/

        1 Reply Last reply
        0

        • Login

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