使用 Qt Creator 进行控制台输入

编程入门 行业动态 更新时间:2024-10-22 09:49:16
本文介绍了使用 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 进行控制台输入

本文发布于:2023-11-25 22:46:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631650.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制台   Qt   Creator

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!