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. console, input, noecho
Qt 6.11 is out! See what's new in the release blog

console, input, noecho

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 766 Views 2 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.
  • Cross_Platform_EnthusiastC Offline
    Cross_Platform_EnthusiastC Offline
    Cross_Platform_Enthusiast
    wrote on last edited by
    #1

    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.

    kshegunovK 1 Reply Last reply
    0
    • Cross_Platform_EnthusiastC Cross_Platform_Enthusiast

      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.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #2

      @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
      0

      • Login

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