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

Qt Designer教程實(shí)例 HelloWorld

移動(dòng)開發(fā)
本文介紹的是Qt Designer教程實(shí)例 HelloWorld ,實(shí)現(xiàn)一個(gè)HelloWorld 的實(shí)例,詳細(xì)內(nèi)容先來看本文!

Qt Designer教程實(shí)例 HelloWorld 是本文要介紹的內(nèi)容,好的,現(xiàn)在我們一起來學(xué)習(xí)使用 QT Designer 設(shè)計(jì)我們的QT應(yīng)用程序?,F(xiàn)在我們做一些準(zhǔn)備工作,我們***為每一個(gè)QT程序建立一個(gè)單獨(dú)的文件夾,這樣就可以讓我們更方便的使用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"對話框,這是一個(gè)新建對話框,我們可以通過從菜單欄的 File->New 來打開它。

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

這樣我們就創(chuàng)建了一個(gè) *.pro 文件。下面我們再創(chuàng)建一個(gè)對話框。

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

這時(shí)侯,你的 QT Designer 中就會(huì)出現(xiàn)一個(gè) From1 來.

更改右下角那個(gè)窗口里的 caption ,原內(nèi)容 "Form1"改為 "我的***個(gè)QT Desiger程序",

name    , 原內(nèi)容 "Form1"改為 "form_main"

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

現(xiàn)在我們點(diǎn)擊一下左邊窗口上面的 ToolBox 中的那個(gè) PushButton (標(biāo)有 OK 的圖標(biāo))

并且用鼠標(biāo)選擇一個(gè)合適的大小. 在這個(gè) PushButton 上面用用鼠標(biāo)雙擊一下,我們就可以改變按鈕上顯示的字了。

這里我們把"pushButton1"這幾個(gè)字,換成 “Hello World!”, 然後用選擇 OK 就可以了.

現(xiàn)在我們看到, 那個(gè)按鈕上的標(biāo)簽已將變成 “Hello World!” 了.

更改右下角那個(gè)窗口"Property Editor"里的 name  , 原內(nèi)容 "pushButton1"改為 "pBtnHello"

我們就算是基本完成了。保存下。 如果想看看這個(gè)小程序長什麼樣子.,可以用 CTRL+T來看 PreView.

這時(shí)侯我們只需要一個(gè)小的 main.cpp 就可以編譯了。同樣我們的 QT Designer 也可以為我們生成 main.cpp 。

從菜單欄的 File->New 打開新建對話框,選擇***一個(gè):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++ -c -pipe -Wall -W -O2 -march=i386 -mcpu=i686 -g -DGLX_GLXEXT_LEGACY -fno-use-cxa-atexit -fno-exceptions  
  4. -DQT_NO_DEBUG -I/usr/lib/qt-3.1/mkspecs/default -I. -I/usr/lib/qt-3.1/include -I.ui/ -I.moc/ -o .obj/main.o main.cpp  
  5. /usr/lib/qt-3.1/bin/uic form1.ui -i form1.h -o .ui/form1.cpp  
  6. g++ -c -pipe -Wall -W -O2 -march=i386 -mcpu=i686 -g -DGLX_GLXEXT_LEGACY -fno-use-cxa-atexit -fno-exceptions 
  7.  -DQT_NO_DEBUG -I/usr/lib/qt-3.1/mkspecs/default -I. -I/usr/lib/qt-3.1/include -I.ui/ -I.moc/ -o .obj/form1.o .ui/form1.cpp  
  8. /usr/lib/qt-3.1/bin/moc .ui/form1.h -o .moc/moc_form1.cpp  
  9. g++ -c -pipe -Wall -W -O2 -march=i386 -mcpu=i686 -g -DGLX_GLXEXT_LEGACY -fno-use-cxa-atexit -fno-exceptions  
  10. -DQT_NO_DEBUG -I/usr/lib/qt-3.1/mkspecs/default -I. -I/usr/lib/qt-3.1/include -I.ui/ -I.moc/ -o .obj/moc_form1.o .moc/moc_form1.cpp  
  11. 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  
  12. [root@localhost DesignerTutorial1]# ls  
  13. form1.ui  form1.ui~  main.cpp  Makefile  tutorial1  tutorial1.pro 

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

運(yùn)行:

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

大功告成。

小結(jié):Qt Designer教程實(shí)例 HelloWorld 的內(nèi)容介紹完了,這里我們學(xué)習(xí)了在LinuxQT Designer 的基本使用方法,并且了解了QT程序的編譯方法,很簡單,不是嗎?***希望本文能幫你解決

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

2011-06-27 16:37:08

Qt Designer

2011-07-04 11:21:59

QT Designer

2011-06-27 16:18:24

Qt Designer

2011-06-27 14:56:46

Qt Designer

2011-06-13 14:29:40

Qt Designer

2014-08-26 11:46:46

QtAndroid實(shí)例教程

2011-07-04 11:29:40

QT Designer

2011-06-10 11:24:08

Qt Quick Designer

2011-07-04 13:26:30

Qt Designer

2011-07-04 13:08:26

Qt Designer

2011-06-13 15:09:36

插件 Qt Designer

2011-07-04 13:17:18

Qt Designer 布局

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-07-04 14:29:25

Qt Designer 容器

2011-07-05 14:46:34

2011-06-21 09:33:49

Qt 啟動(dòng) 界面

2009-03-16 15:00:16

阿里軟件旺旺軟件平臺SaaS
點(diǎn)贊
收藏

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