在Ubuntu 12.04下采用apt-get的方法安裝Qt4。
First: sudo apt-get install libqt4-dev libqt4-dbg libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig
Second: 測試 個人實例
在桌面創建文件夾qt4hello(mkdir qt4hello)---> vim qthello.cpp --->輸入:以下代碼
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello ubuntu12.04 LTS!");
hello.resize(190, 150);
hello.show();
return app.exec();
}
----> 保存(:wq)--->qmake -project(生成QT項目)--->qmake(生成makefile文件)--->make 出現以下代碼
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o qthello.o qthello.cpp
g++ -m64 -Wl,-O1 -o qt4hello qthello.o -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread
--->./qt4hello(文件夾的名稱)
Qt 的詳細介紹:請點這裡
Qt 的下載地址:請點這裡
推薦閱讀:
Ubuntu 環境下Gtk與QT編譯環境安裝與配置 http://www.linuxidc.com/Linux/2013-08/88539.htm
Linux系統下QT環境搭建 http://www.linuxidc.com/Linux/2013-07/87576.htm
Ubuntu下QT控制台程序無法運行的解決方案以及XTerm的配置方法 http://www.linuxidc.com/Linux/2013-06/86244.htm
Ubuntu 10.04下QT4.7.4移植詳解 http://www.linuxidc.com/Linux/2013-01/77930.htm
更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2