Using cin in QtCreator

和自甴很熟 提交于 2019-12-05 02:07:00

In Preferences, under the Environment section, set the "Terminal" option to /Applications/Utilities/Terminal.app, as pointed out by Alex Martelli.

Then, in the Projects tab, under Run Settings, check the box marked "Run in Terminal".

Now, QtCreator will use Apple's built-in Terminal.app instead of Qt's console, allowing for interactive input.

If you're doing "console"-style apps with no GUI, Qt Creator may not be the most appropriate IDE -- why not try Apple's own XCode, which probably comes on your OS DVD (as a separate installer), and worst-case can be freely downloaded by registering at Apple Developer Connection?

Edit: as the OP indicates that all they need is the location to Mac's terminal app, that's easy: it's /Applications/Utilities/Terminal.app.

Huffy
#include <QCoreApplication>
#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    std::string name;
        std::cout << "Enter name: ";
        std::cin >> name;
        std::cout << "Your name is " << name << std::endl;


    return a.exec();
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!