1. install qt5
sudo apt-get install qt5-default qttools5-dev-tools
2. install g++
sudo apt-get install g++
3. install vim
sudo apt-get install vim
4. test:
4.1 mkdir hello_qt folder and create hello_qt.cpp file as follow :
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello QT!");
label->show();
return app.exec();
}
4.2
qmake -project
4.3 add
QT += widgets
into hello_qt.pro file
4.4 qmake hello_qt.pro
4.5 make
4.6 run ./hello_qt
5. some informations:
Qt4过渡至Qt5
QtWebKitWidgets也是一个独立的模块:
例如编译时错误
-
error:
invaliduse of incomplete type 'classQWebFrame' -
error :
forwarddeclaration of 'classQWebFrame'
解决办法:
在*.pro文件里添加:
-
QT
+= webkitwidgets
注意:当有QT+= webkitwidgets的时候,就不再需要QT += widgets
6. install QT4:
sudo apt-get install libqt4-dev libqt4-dbg libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig
use the follow command to compile the code:
qmake-qt4 -project;
qmake-qt4 *.pro
make