I wrote this program in Qt Creator but I’m not sure how to run it. Here is my code:
#include <QtCore/QCoreApplication>
using namespace std;
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
string str;
cin >> str;
cout << " str is : " << str;
return a.exec();
}
When I run it my console shows this:
Starting /home/hamed/qt programs/test3-build-desktop/test3...
…and nothing happens. What should I do?
When copy pasting your code, it runs for me as expected (well, it doesn’t terminate, but runs). Here is what I did in command line:
As mentioned in the comment above, Qt itself is a library, so you are probably referring to some IDE when saying running it from “within Qt” – behaviour there is solely dependent on what IDE you are using.
Update:
From your message
I assume that you are using the QtCreator IDE, which does not allow you to enter things to console when running. I don’t know whether you can get it to do so, but it works if you enter your project directory in console and use
./projectname. The building part mentioned above will be handled by QtCreator.Another update:
Check out this thread for information on how to get it to work directly from QtCreator.