Now that you have already installed Eclipse, Qt Framework Open Source and MinGW with the this tutorial, we will create our first program window.
Let's go.
Open Eclipse, on the Explorer > Right Click > New Project > Qt > Qt Gui Project.
Write a project name such as hello-world, then Next, Next, Finish.
A lot of files and directories are created for you.
Delete all.
So now your directory hello-world is empty.
Create a main.cpp file.
Inside write this:
#include <QtGui> #include <QApplication> int main(int argc, char *argv[]) { QApplication app(argc, argv); QTextEdit textEdit; textEdit.setWindowTitle("Our first window :D"); textEdit.setText("Hello, you can write here."); textEdit.show(); return app.exec(); }
Now open a MinGW shell by running this file: C:\soft\min-gw\msys\1.0\msys.bat
Go until the project directory and write this command:
ls
The shell displays just the main.cpp file.
OK, let's create all files needed for our executable.
In the same directory type this:
qmake -project
Then:
ls
A new file has appeared, the hello-world.pro one.
The tool qmake is a software created by Nokia company for using Qt.
So the file with a .pro extension are used by qmake to generate all others files.
Let's continue and simply type this in the shell:
qmake
Then once again:
ls
You are seeing 5 files:
And 2 directories:
Let's finish by compiling our project:
make release
Open your directory hello-world\release and double click the hello-world.exe to see the window appears.
You want now send this program to your best friend.
He has also a Windows OS but without QT nor MinGW installed in his computer.
You have to send him the .exe with all files required to execute this program.
These files are:
You can find them respectively in:
So, do not forget to send these files with the .exe if you expect that your friend see the window program appears.
Otherwise he should have great errors such as:
Great job, you made it!
Add new comment