I am new in Qt and tried to start to write a simple pure C++ program in it. I created a new project and my.pro file looks like below:
TEMPLATE = app
TARGET = testgraph
QT = core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += \
main.cpp
and my main.cpp file is:
#include <iostream>
using namespace std;
int main(){
int n;
cout << "type an integer: " << endl;
cin >> n;
cout << "you have typed: " << n << endl;
return 0;
}
and then I pressed the Build button and then Run. It seems like the program is working but it could't reach to assigning n the value I had just typed in,
after I typed 4 and pressed Enter, I expected it to break the line and return "you have typed 4" but the cursor just started a new line and nothing happened.
Is this because something wrong in.pro file?
Your .pro
file shows that you have created a GUI app but your requirement is to create a pure C++ project.
Follow these steps:
File
menuNew Project
Non-Qt Project
from the dialog boxPlain C++ Application
from the list on the right After setting this up, your code should run.
The project wizard will offer to select a build system. If your project is a CMake or makefile project, select accordingly. Otherwise, you can select QMake and it'll generate a makefile for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.