I'm developping a very simple app on my Mac using QtCreator.
It's a console application and I want the user to enter its name, and then I display his name. Here is the code :
#include <iostream>
int main(int ArgC, char* ArgV[])
{
char Name[1000];
std::cout << "Type your name : ";
std::cin >> Name;
std::cout << "Hello " << Name << "\n";
return 0;
}
When running this app with QtCreator, the string "Type your name :" is displayed in the 'Application Output' tab. But if I type some text and press the enter key, nothing is happening.
What's wrong ?
Go to Project -> Run settings, and make sure "Run in Terminal" is checked.
BTW:
is probably not what you want. It will read just a single token (typically only the first name). You should have a look at getline, or the string version.
Solution for Windows.
In the .pro file add:
Go to Project -> Run settings, and make sure "Run in Terminal" is checked.
I had the "Cannot start the terminal emulator 'xterm'" problem on Mac and fixed it by going to settings, Environment and clicking the "Reset" button next to the Terminal text field.
For some reason by default it just said "xterm -e" but after the reset it became an absolute path of "/usr/X11/bin/xterm -e".
My console app then ran fine.
Jeromes solution is the proper one. Though I can give you a different alternative. In case you don't want to use X11 (for some reason anyhow) in the same position (QtCreator->Preferences->Environment:General:Terminal) you can give your path to the Terminal application like this: /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal
Enjoy!
For Mac-based Qt 2.4.0, click on the Project vertical tab, which is located below the "Debug" along the same vertical line as Welcome, Edit, Design. In Target-> Run, make sure "Run in terminal" is checked!
I found a solution. With Qt Creator 1.3.0 (on Mac OS X), here is what I had to do :
/usr/x11/bin/xterm -e
.Now, everything is working fine !