Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved console, input, noecho

    General and Desktop
    2
    2
    521
    Loading More Posts
    • 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.
    • Cross_Platform_Enthusiast
      Cross_Platform_Enthusiast last edited by

      Does Qt provide a portable way to read a character from console without waiting for "Enter" and with no echo? On Windows it's "_getch()", but on Linux you have to configure stdin using termios.h -> tcsetattr(). I hear on Mac it's something else...
      Thanks in advance.

      kshegunov 1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators @Cross_Platform_Enthusiast last edited by kshegunov

        @Cross_Platform_Enthusiast
        Hello,
        I don't know about the "echo", I don't think Qt provides a way to configure the terminal (it'd go way beyond scope), however you can read from the standard input with QTextStream in a portable manner:

        QTextStream cin(stdin);
        
        QChar character;
        cin >> character;
        

        Kind regards.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply Reply Quote 0
        • First post
          Last post