使用 Qt Creator 进行控制台输入 [英] Console input with Qt Creator
本文介绍了使用 Qt Creator 进行控制台输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 QtCreator 在我的 Mac 上开发一个非常简单的应用程序.
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;
}
使用 QtCreator 运行此应用程序时,应用程序输出"选项卡中会显示字符串键入您的姓名:".但是,如果我输入一些文本并按 Enter 键,则什么也没有发生.
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.
怎么了?
推荐答案
我找到了解决方案.使用 Qt Creator 1.3.0(在 Mac OS X 上),这是我必须做的:
I found a solution. With Qt Creator 1.3.0 (on Mac OS X), here is what I had to do :
- 项目->运行设置,勾选在终端中运行"(感谢 Ropez)
- Qt Creator->Preferences : Environnement : General : Terminal :我必须把整个路径放到 XTerm 中.对于我的配置,我必须输入
/usr/x11/bin/xterm -e
.
现在,一切正常!
这篇关于使用 Qt Creator 进行控制台输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文