I assume that your environment is OK to program a Qt.By the way all code is done on Ubuntu.
Step1: program a Qt demo in QtProject folder.
#include <QApplication>
#include <QLabel>
#include <QWidget>
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
QLabel hello("<center>Welcome to my first Qt program</center>");
hello.setWindowTitle("My first Qt program");
hello.resize(400,400);
hello.show();
return app.exec();
}
To save above code in a file testmain.cpp.
Step2: generate a .pro
file which is used to generate a Makefile
~/QtProject$ qmake -project
~/QtProject$ ls
QtProject.pro testmain.cpp
Step3: add QT += gui widgets
to the end of QtProject.pro file.
Step4: to generate a Makefile
file which is used to compile the program.
~/QtProject$ qmake QtProject.pro
kyunban@kyunban:~/QtProject$ ls
Makefile QtProject.pro testmain.cpp
Step5: compile this program
~/QtProject$ make
~/QtProject$ ls
Makefile QtProject QtProject.pro testmain.cpp testmain.o
Finally, we get a executable file QtProject
,run it with below command:
~/QtProject$ ./QtProject