偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

Qt 編程點(diǎn)滴 初學(xué)者必看 (3)

移動(dòng)開發(fā)
本人介紹的是Qt 編程點(diǎn)滴,作為一名新手,我建議必須看一看。編程那些事,只有編程人員自己明白!所以推薦本文。

Qt 編程繼續(xù)為大家講解,還是接著文章 Qt 編程點(diǎn)滴 初學(xué)者必看 (2) ,繼續(xù)介紹,說編程那些細(xì)節(jié)。由于本話題是一節(jié)一節(jié)為大家介紹的,所以更多內(nèi)容請看末尾編輯推薦。

靜態(tài)成員變更量

  1. aa.h  
  2. class AA  
  3. {  
  4.   static char p[13];  
  5. };  
  6. aa.cpp  
  7. char AA::p[13];  

如果沒在cpp中增加"char AA::p[13];",則編譯時(shí)會(huì)提示"undefined reference to...."的錯(cuò)誤

b.h接口中引用a.h接口,使用時(shí)必須加上

  1. include "a.h"  
  2. include "b.h" 

否則編譯時(shí)會(huì)出現(xiàn)"如果沒在cpp中增加"char AA::p[13];",則編譯時(shí)會(huì)提示"單例模式singleton單元要最先初始化(#include放到最前面)

QWidget類以模式窗體顯示:

  1. dailPage = new DailForm(0,tel);  
  2. dailPage->setWindowModality(Qt::ApplicationModal);  
  3. dailPage->show();   

事件過濾寫法:

其實(shí)可以通過重載QWidget::keyPressEvent()獲得本類(假設(shè)是窗體)中的幾乎所有鍵盤事件,但焦點(diǎn)在文本框上,就不屬于窗體類啦,所以必須采用在窗體類中添加Event Filters:

  1. CustomerInfoDialog::CustomerInfoDialog(QWidget *parent)  
  2.   : QDialog(parent)  
  3. {  
  4.   ...  
  5.   firstNameEdit->installEventFilter(this);  
  6.   lastNameEdit->installEventFilter(this);  
  7.   cityEdit->installEventFilter(this);  
  8.   phoneNumberEdit->installEventFilter(this);  

然后在eventFilter中處理相關(guān)鍵盤事件,通過target判斷是否是文本框發(fā)生的鍵盤事件

  1. bool CustomerInfoDialog::eventFilter(QObject *target, QEvent *event)  
  2. {  
  3.   if (target == firstNameEdit || target == lastNameEdit  
  4.         || target == cityEdit || target == phoneNumberEdit) {  
  5.     if (event->type() == QEvent::KeyPress) {  
  6.         QKeyEvent *keyEvent = static_cast(event);  
  7.         if (keyEvent->key() == Qt::Key_Space) {  
  8.           focusNextChild();  
  9.           return true;  
  10.         }  
  11.     }  
  12.   }  
  13.   return QDialog::eventFilter(target, event);  

去掉窗體標(biāo)題欄:

  1. setWindowFlags(Qt::FramelessWindowHint);  
  2. ld.exe cannot find -lSDL  

處理:環(huán)境變量path加入"D:\QtDevelop\umpcapp\public\SDL-1.2.13\bin"

環(huán)境變量path的設(shè)置:

  1. D:\QtDevelop\umpcapp\public\STLport-5.1.3\bin;  
  2. D:\MinGW\bin;  
  3. D:\Qt\bin;  
  4. D:\QtDevelop\umpcapp\public\SDL-1.2.13\bin;  
  5. D:\QtDevelop\umpcapp\public\SDL_mixer-1.2.8\bin 

注:STLport-5.1.3一定要放在MinGW前面,不然會(huì)出現(xiàn)"QImage: out of memory, returning null image"的錯(cuò)誤;如果要用到STLport庫,那么在配置.pro文件時(shí),一定要記住把stlport放在其它庫的前面,下面的寫法是正確的:

  1. INCLUDEPATH += . \  
  2.                ../../public/STLport-5.1.3/stlport \ ###這句一定要放在前面  
  3.                ../../public/SDL-1.2.13/include \  
  4.                ../../public/common/include \  
  5.                ../../public/qextserialport-1.1\  
  6.                ../../public/boost-1.37.0/include 

如果庫的依賴關(guān)系(*.dll)出錯(cuò),則應(yīng)用程序會(huì)出現(xiàn)報(bào)內(nèi)存的錯(cuò)誤,最簡單的方法就是把應(yīng)用程序,所需要的庫直接加入環(huán)境變量path中,以造成如果庫更新,原來拷在應(yīng)用程序下的庫沒有及時(shí)更新,環(huán)境變更path的設(shè)置例子:

  1. path += D:\QtDevelop\umpcapp\public\boost-1.37.0\lib;  
  2.         D:\QtDevelop\umpcapp\public\qextserialport-1.1\build  

上面對應(yīng)的庫為:

  1. boost_system-mgw34-mt-1_37.dll;boost_thread-mgw34-mt-1_37.dll;  
  2. qextserialport.dll                  

編譯成功后,debug下的exe文件不能生成,請檢查.pro文件中,HEADERS與SOURCES參數(shù)配置是否有錯(cuò)誤,比如把.h文件加入SOURCES參數(shù)中,把.cpp加入HEADERS參數(shù)中.

  1. void MapScene::mouseMoveEvent ( QGraphicsSceneMouseEvent * mouseEvent )  
  2. {  
  3.     QPointF scenepos;  
  4.     scenepos = mouseEvent->scenePos();  
  5.     //qDebug()< 

QWebKit中支持Flash播放的代碼(Qt4.5才支持Flash)

  1. webView->page()->settings()->setAttribute(QWebSettings::PluginsEnabled,true);  
  2. listWidget->addItem(new QListWidgetItem(QIcon(":/notepaditem.png"), QFile(files[i]).fileName()  )); 

vector 引用的單元:

  1. #include   
  2. using namespace std;  
  3. QString 字符串換行:  
  4. QString str;  
  5. str = tr("133");  
  6. str.append(tr("  
  7. ")); 

注:br后要加一個(gè)空格;

Qss背景透明:

  1. QPushButton{  
  2.     background-color: rgba( 255, 255, 255, 0% );  

打開指定URL地址

  1. QUrl url("http://www.zzwtt.com");  
  2. QDesktopServices::openUrl(url); 

可以打開任意URL

窗體置前:

  1. QWidget w;  
  2.    w.setWindowFlags(Qt::WindowStaysOnTopHint);  
  3.    w.show(); 

窗體不顯示在任務(wù)欄:

  1. setWindowFlags(Qt::Popup) ; 

注:改變*.h的內(nèi)容,編譯時(shí)會(huì)沒有編譯過程,只有改變*.cpp才會(huì)進(jìn)行編譯;

小結(jié):本文主要介紹了在Qt 窗體的使用,通過Qt 編程點(diǎn)滴介紹,也給自己提高了編程過程中需要注意的細(xì)節(jié)問題,由于本話題是一節(jié)一節(jié)為大家展現(xiàn)的,所以更多內(nèi)容,請看編輯推薦。

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

2011-06-17 15:19:28

Qt

2011-06-17 15:25:18

Qt

2011-06-17 15:37:42

Qt

2011-06-17 15:44:25

Qt

2011-06-17 14:54:31

Qt

2011-06-17 14:12:32

Qt

2011-06-17 15:06:14

Qt

2011-06-17 14:29:55

Qt

2011-06-17 15:32:28

Qt

2011-09-16 09:38:19

Emacs

2011-06-27 14:56:46

Qt Designer

2011-09-08 10:38:37

Widget

2013-04-23 10:51:15

Linux壓縮

2011-08-24 17:05:01

Lua

2009-11-17 15:33:26

PHP數(shù)組元素

2009-10-22 16:46:03

VB.NET初步知識

2011-07-26 17:55:16

iPhone Runtime

2011-08-04 18:01:07

IOS Cocoa Touc

2009-10-29 09:19:59

ADO.NET

2011-08-30 11:23:16

無線網(wǎng)卡怎么用無線網(wǎng)卡無線上網(wǎng)卡
點(diǎn)贊
收藏

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