在Ubuntu 12.04下採用apt-get的方法安裝Qt4

來源:互聯網
上載者:User

在Ubuntu 12.04下採用apt-get的方法安裝Qt4。
 
運行:
 
一、$ sudo apt-get install libqt4-dev libqt4-debug libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig
 
上面列出的是qt配置環境所必須的軟體包,比如qt4-dev-tools 包含了Qt Assistant及Qt Linguist等工具,因此不需要單獨安裝這兩個工具。其它的,qt4-doc 是協助文檔,包含了Qt中各個類庫的詳細說明以及豐富的例子程式,可以使用Qt Assistant 工具來開啟閱讀。qt4-qtconfig 是配置Qt環境的一個對話方塊,一般預設就行了,很少有必要去更改。qt4-demos 包含很多可以運行起來的可執行檔以及原始碼。qt4-designer是用來設計GUI介面的設計器
 
注意
 
二、$ sudo apt-get install libqt4-debug 在安裝這個軟體的時候系統可能提示:
正在讀取軟體包列表... 完成
正在分析軟體包的相依樹狀結構     
正在讀取狀態資訊... 完成     
現在沒有可用的軟體包 libqt4-debug,但是它被其它的軟體包引用了。
這可能意味著這個缺失的軟體包可能已被廢棄,
或者只能在其他發布源中找到
可是下列軟體包取代了它:
  libqt4-dbg:i386 libqt4-dbg
所以這時候我們採用
$ sudo apt-get install libqt4-dbg代替
等到全部安裝完畢後,我們來用一個程式試試
 
三、首先編寫原始碼。 建立檔案夾qt4hello,然後再裡面建立檔案 Qthello.cpp,內容如下:
 
#include <QApplication> #include <QPushButton>    int main(int argc, char *argv[]) {             QApplication app(argc, argv);              QPushButton hello("Hello Ubuntu!");             hello.resize(100, 30);               hello.show();             return
app.exec();  }
在終端輸入:$ gedit Qthello.cpp(輸入上面的程式)
                     $qmake -project(產生Qt項目)
                     $qmake(產生makefile檔案)
                     $make
出現g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o QtHello.o QtHello.cpp
g++ -o qtsrc QtHello.o -L/usr/lib -lQtGui -lQtCore -lpthread
最後             $ ls
          Makefile  qt4hello  qt4hello.pro  Qthello.cpp  Qthello.o
接著           $ ./qt4hello 在螢幕上顯示一個hello的小視窗,至此安裝完畢

本篇文章來源於 Linux公社網站(www.linuxidc.com)  原文連結:http://www.linuxidc.com/Linux/2012-05/60770.htm

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.