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::readLine() returns null
Forum Updated to NodeBB v4.3 + New Features

QTextStream::readLine() returns null

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 327 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.
  • P Offline
    P Offline
    PaulHuber
    wrote on last edited by
    #1

    I am using QT6.8.2 on windows. In a Qt console app the following readLine does not wait for user input and returns "" immediately. Can somebody advise.

    #include <QCoreApplication>
    #include <QTextStream>
    #include <QDebug>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    qDebug() << "\nType in your search phrase:\n";
    
    QTextStream s(stdin);
    const auto phrase = s.readLine();
    
    qDebug() << " you entered" << phrase;
    return a.exec();
    

    }

    JonBJ 1 Reply Last reply
    0
    • JonBJ JonB

      @PaulHuber
      Also read through Application output does not wait for QTextStream readLine();. Per the last post there, are you running this from Command Prompt or from Creator?

      P Offline
      P Offline
      PaulHuber
      wrote on last edited by
      #4

      @JonB Tks issue resolved. Running from the command prompt functions normally. The application output window from creator does not allow user input.

      JonBJ 1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #2

        Try with bitshift operator:

        QString input;
        s >> input;
        

        (Z(:^

        1 Reply Last reply
        0
        • P PaulHuber

          I am using QT6.8.2 on windows. In a Qt console app the following readLine does not wait for user input and returns "" immediately. Can somebody advise.

          #include <QCoreApplication>
          #include <QTextStream>
          #include <QDebug>

          int main(int argc, char *argv[])
          {
          QCoreApplication a(argc, argv);

          qDebug() << "\nType in your search phrase:\n";
          
          QTextStream s(stdin);
          const auto phrase = s.readLine();
          
          qDebug() << " you entered" << phrase;
          return a.exec();
          

          }

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #3

          @PaulHuber
          Also read through Application output does not wait for QTextStream readLine();. Per the last post there, are you running this from Command Prompt or from Creator?

          P 1 Reply Last reply
          1
          • JonBJ JonB

            @PaulHuber
            Also read through Application output does not wait for QTextStream readLine();. Per the last post there, are you running this from Command Prompt or from Creator?

            P Offline
            P Offline
            PaulHuber
            wrote on last edited by
            #4

            @JonB Tks issue resolved. Running from the command prompt functions normally. The application output window from creator does not allow user input.

            JonBJ 1 Reply Last reply
            0
            • P PaulHuber has marked this topic as solved on
            • P PaulHuber

              @JonB Tks issue resolved. Running from the command prompt functions normally. The application output window from creator does not allow user input.

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by JonB
              #5

              @PaulHuber
              Yes, as per the answer there. The Application Output pane is only for output. I believe current Creator has an alternative "terminal setting" these days, which allows a genuine terminal with input as well as output allowed if you want to use it that way.

              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