-1

I want to make cin>> work in QT, so it's needed to use the external terminal, not the application output.

I followed all the instructions given in the previous answers about cin>> not working, but I can't make it work on QT creator 15:

  • I set: "run in terminal"
  • I de-select "show in application output when running"
  • I added the cmd.exe path in edit->preferences->environment->patch command

The terminal opens, but the only thing that is output is: Press to close this window...

My simple code:

#include <iostream> using namespace std; int main() { string a; cout <<"enter any string" << endl; cin >> a; cout << endl; cout << "I understood: " << a << endl; return 0; } 
5
  • This isn't expected. Use your debugger to see what is happening. Set a breakpoint after the first cout and see what happens. Commented Jan 24 at 22:23
  • I added one breakpoint at every step from the first cout. The terminal is empty until the return 0 command when the message describes avive is output. Also creator application output remains with "debugging...." Line until "has finished with exit code exit code 0" comes at the return 0 command Commented Jan 25 at 11:24
  • I found the problem, you need to create a console project. A widget project is not allowed to output to the external terminal. Commented Jan 25 at 11:48
  • Are you on MS Windows? Commented Jan 25 at 14:10
  • Yes Windows 11. Commented Jan 26 at 15:34

1 Answer 1

0

2 Steps are required to make Creator not redirect the console output to its internal console:

a) Go to the Build & Run Settings of your project, select Run, in the Run Section, select "Run in terminal"

enter image description here

b) Go to the Application Output Pane. There is a wheel indicating the settings for the Aplication Output. Press it and select the "Terminal" section. There disable "Use internal terminal".

enter image description here

That's all. Pretty unintuitive:-)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.