自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

QT Designer學(xué)習(xí)教程

移動開發(fā)
本文介紹的是QT Designer學(xué)習(xí)教程,QT Designer相信友們并不是很陌生,那么先來看本文詳細講解吧。

QT Designer學(xué)習(xí)教程 是本文要介紹的內(nèi)容,不多說,先來看內(nèi)容。好的,現(xiàn)在我們一起來學(xué)習(xí)使用 QT Designer 設(shè)計我們的QT應(yīng)用程序。

現(xiàn)在我們做一些準備工作,我們最好為每一個QT程序建立一個單獨的文件夾,這樣就可以讓我們更方便的使用QT為我們提供的工具,例如qmake等。

  1. [root@localhost test]# mkdir /root/DesignerTutorial1  
  2. [root@localhost test]# cd /root/DesignerTutorial1 

然后打開 QT Designer ,直接在命令行下輸入:designer,如下:

  1. [root@localhost DesignerTutorial1]# designer&  
  2. [3] 16544  
  3. [root@localhost DesignerTutorial1]# 

這里我們看到"Qt Designer - New/Open"對話框,這是一個新建對話框,我們可以通過從菜單欄的 File->New 來打開它。

我們先選擇對話框上的第一個"C++ Project",確定,然后更改名字,這里我們改為 tutorial1.pro 保存,默認情況是保存到我們剛剛創(chuàng)建的文件夾 /root/DesignerTutorial1,這樣我們就創(chuàng)建了一個 *.pro 文件。下面我們再創(chuàng)建一個對話框。

從菜單欄的 File->New 打開新建對話框,選擇第二個:Dialog,然后也同樣保存到剛剛創(chuàng)建的文件夾 /root/DesignerTutorial1 下。

這時侯,你的 QT Designer 中就會出現(xiàn)一個 From1 來. 更改右下角那個窗口里的 caption ,原內(nèi)容 "Form1"改為 "我的第一個QT Desiger程序"

  1. name     
  2. 內(nèi)容 "Form1"改為 "form_main" 

可以看到這時候窗口的標(biāo)題欄文字已經(jīng)改變?yōu)?quot;Form1"改為 "我的第一個QT Desiger程序",不是嗎?

現(xiàn)在我們點擊一下左邊窗口上面的 ToolBox 中的那個 PushButton (標(biāo)有 OK 的圖標(biāo))并且用鼠標(biāo)選擇一個合適的大小. 在這個 PushButton 上面用用鼠標(biāo)雙擊一下,我們就可以改變按鈕上顯示的字了。

這里我們把"pushButton1"這幾個字,換成 “Hello World!”, 然後用選擇 OK 就可以了. 現(xiàn)在我們看到, 那個按鈕上的標(biāo)簽已將變成 “Hello World!” 了. 更改右下角那個窗口"Property Editor"里的 name  , 原內(nèi)容 "pushButton1"改為 "pBtnHello"我們就算是基本完成了。

保存下。 如果想看看這個小程序長什麼樣子.可以用 CTRL+T來看 PreView. 這時侯我們只需要一個小的 main.cpp 就可以編譯了。同樣我們的 QT Designer 也可以為我們生成 main.cpp 。

從菜單欄的 File->New 打開新建對話框,選擇最后一個:C++ Main-File(main.cpp).

然后也同樣保存到剛剛創(chuàng)建的文件夾 /root/DesignerTutorial1 下。

好了,現(xiàn)在來編譯我們的程序。

生成Makefile文件:

  1. [root@localhost DesignerTutorial1]# qmake 

編譯:

  1. [root@localhost DesignerTutorial1]# make  
  2. /usr/lib/qt-3.1/bin/uic form1.ui -o .ui/form1.h  
  3. g++  
  4. -c -pipe -Wall -W -O2 -march=i386 -mcpu=i686 -g -DGLX_GLXEXT_LEGACY  
  5. -fno-use-cxa-atexit -fno-exceptions  -DQT_NO_DEBUG  
  6. -I/usr/lib/qt-3.1/mkspecs/default -I. -I/usr/lib/qt-3.1/include -I.ui/  
  7. -I.moc/ -o .obj/main.o main.cpp  
  8. /usr/lib/qt-3.1/bin/uic form1.ui -i form1.h -o .ui/form1.cpp  
  9. g++  
  10. -c -pipe -Wall -W -O2 -march=i386 -mcpu=i686 -g -DGLX_GLXEXT_LEGACY  
  11. -fno-use-cxa-atexit -fno-exceptions  -DQT_NO_DEBUG  
  12. -I/usr/lib/qt-3.1/mkspecs/default -I. -I/usr/lib/qt-3.1/include -I.ui/  
  13. -I.moc/ -o .obj/form1.o .ui/form1.cpp  
  14. /usr/lib/qt-3.1/bin/moc .ui/form1.h -o .moc/moc_form1.cpp  
  15. g++  
  16. -c -pipe -Wall -W -O2 -march=i386 -mcpu=i686 -g -DGLX_GLXEXT_LEGACY  
  17. -fno-use-cxa-atexit -fno-exceptions  -DQT_NO_DEBUG  
  18. -I/usr/lib/qt-3.1/mkspecs/default -I. -I/usr/lib/qt-3.1/include -I.ui/  
  19. -I.moc/ -o .obj/moc_form1.o .moc/moc_form1.cpp  
  20. g++  -o tutorial1 .obj/main.o .obj/form1.o .obj/moc_form1.o  -L/usr/lib/qt-3.1/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm  
  21. [root@localhost DesignerTutorial1]# ls  
  22. form1.ui  form1.ui~  main.cpp  Makefile  tutorial1  tutorial1.pro 

可以看到 tutorial1 ,這就是我們的可執(zhí)行程序,

運行:

  1. [root@localhost DesignerTutorial1]# ./tutorial1 

大功告成。

總結(jié):關(guān)于QT Designer學(xué)習(xí)教程 的內(nèi)容介紹完了,這里我們學(xué)習(xí)了在LinuxQT Designer 的基本使用方法,并且了解了QT程序的編譯方法,很簡單,不是嗎?最后希望本文對你有所幫助!

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-07-04 11:29:40

QT Designer

2011-06-27 16:07:49

Qt Designer

2011-06-27 16:37:08

Qt Designer

2011-06-27 16:18:24

Qt Designer

2011-07-04 13:26:30

Qt Designer

2011-07-04 13:08:26

Qt Designer

2011-07-04 13:17:18

Qt Designer 布局

2011-06-27 14:56:46

Qt Designer

2011-06-13 14:29:40

Qt Designer

2011-06-10 11:24:08

Qt Quick Designer

2011-08-30 15:32:08

QtQuickQML

2011-09-07 16:28:46

QT WidgetQWidget

2011-06-13 15:09:36

插件 Qt Designer

2011-09-01 16:01:25

Qt插件

2011-08-30 15:49:03

QtQuick

2011-06-28 17:13:46

Qt Designer UI

2011-06-13 14:49:57

Qt Designer

2011-06-13 14:00:55

Qt Designer linux

2011-06-20 15:52:14

Qt Designer 控件

2011-06-27 12:56:28

點贊
收藏

51CTO技術(shù)棧公眾號