Important: Please read the Qt Code of Conduct -

Valgrind in QtCreator: console input failing

  • I have a simple HelloWorld type project using QtCreator as a code editor. Here is the source:
    #include <iostream>
    #include <string>

    int main() {
    std::cout << "Hello World!" << std::endl;

    std::cout << "Enter your name: ";
    std::string name;
    std::cin >> name;
    std::cout << "Hello " + name << std::endl;

    return 0;
    If I check the 'Run in terminal' box in the project Run Settings, it Runs fine, opening a separate terminal window(not the Application Output window in QtCreator), which cout/cin happily write/read to/from. If I de-select the aforementioned 'Run in terminal' box, click Run, it opens the Application Output window in QtCreator, writes to it, but is unable to read from it. This is all fine with me -I just make sure to always select 'Run in terminal' for such console applications; GDB and everything runs fine with i/o directing there.

    Now the problem is that when I click 'Analyze', select either Valgrind Memory Analyzer or Valgrind Function Profiler, click the Start button, the Application Output window opens(within QtCreator) rather than the seperate terminal window opening, REGARDLESS of whether I have checked the aforementioned 'Run in terminal' box! So it is again unable to read any user input.
    How to use cout/cin to write/read to/from this simple program running under Valgrind?

  • Is cin/cout io not possible while running Valgrind?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You should try to bring this question to the Qt-Creator mailing list, you'll find there Qt Creator's developers/maintainers. This forum is more user oriented

Log in to reply