0
votes

i am new to qt. Trying to run some simple application in QtCreator 3.2.1 which is based on QT5 on Debian system.

i create c++ plain project with cmake

#include <iostream>

using namespace std;

int main()
{
    string name;

    cout << "please enter your name:\n";
    cin >> name;
    cout << "hello" << name << "\n";

    return 0;
}

The problem is that when i launch the application, and input some string. The application console dont have any resp.

I confirm that the application can be run in my gnome-terminal.

After that, i check the same message from the stackoverflow. there is a solution "set project run in terminal".

Then i look for that on the QtCreator 3.2.1. I cant find that menu. Only have the terminal setting.

unfortunately, whichever i choose, 1. /usr/bin/xterm -e 2. /usr/bin/gnome-terminal -x 3. /usr/bin/x-terminal-emulator -e the problem still exist.

1
I'm not familiar with QtCreator, but could you try adding a #include <string> to your source? I've had a problem before where the >> operator was not defined until I included <string> to my source. - Nard
i already found run in terminal in the projects setting. it is not run in the application console, it will launch a new gnome-terminal to run the helloword. thx! - chuck

1 Answers

1
votes

you must choose the "Run in Terminal" if you create CMake project with C++ enter image description here