Reputation: 2011
I want to make a GUI application using Qt and am not able to get started. I wrote the following code in my editor:
#include <QApplication>
#include <QWidget>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QWidget window;
window.resize(250,150);
window.setWindowTitle("Simple example");
window.show();
return app.exec();
}
Then I make a project.pro
file in my current directory with the following content:
SOURCES = qt.cpp
HEADERS = QApplication QWidget
CONFIG += qt warn_on release
Then I type in terminal, qmake -project
but the terminal does nothing. Even the command prompt doesn't appear. It just sits idle as if waiting for something, like the following:
user@user:~$ qmake -project
_
How do I make it work?
Upvotes: 0
Views: 410
Reputation: 5741
The following line creates a project source file for you.
> qmake -project
The only thing in this case you need is .cpp & .h files for your project.
Now, remove your project source file you've created. In the directory, you need only .cpp & .h for your project (in your case there is only qt.cpp). Now, go to the terminal and type
> qmake -project -o myproject.pro
This line created a project source file for you and its name is "myproject".
Type (assuming there is only one project source file)
> qmake
The above line created the Makefile.
Now, type
> make
The output (by default in mac) has the extension .app and its name is myproject.app. Now to run it (in mac).
> open myproject.app
As you see, you don't have full control over your project. To overcome this problem, you need to create your own project source file ( which I prefer that).
Upvotes: 1