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

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

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

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

刪ITEM方法:

把把ITEM的數(shù)據(jù)掛到指針上,先刪ITEM,然后再刪除指針

如果發(fā)生 no such file or directory not find(報(bào)Qt核心文件錯(cuò))

有可能是project --properties--projects settings中的"This is a custom MakeFile"沒有勾選;

檢查.pro文件是   INCLUDEPATH += DEPENDPATH+= 有沒加入文件所在的目錄

檢查.pro文件是否引入兩個(gè)版本不同的相同文件名的文件;

枚舉類型做為信號(hào)的參數(shù),則需對(duì)枚舉類型進(jìn)行注冊(cè)

在include中

  1. //定義Enum  
  2. typedef enum{  
  3.     ProgressType,  
  4.     StartType,  
  5.     SuccessType,  
  6.     StopType  
  7. }  
  8. SyncMsgType;    //定義結(jié)構(gòu)  
  9. typedef struct  //實(shí)際使用中可以多增加些結(jié)構(gòu)成員  
  10. {  
  11.     SyncMsgType msgtype;  
  12. }SyncMsg;  
  13. Q_DECLARE_METATYPE(SyncMsg) 

在應(yīng)用程序.CPP中

  1. //連接之前再注冊(cè)  
  2.     qRegisterMetaType("SyncMsg");  
  3.     connect(gpssyncthread, SIGNAL(syncMsgNotify(SyncMsg)),  
  4.             this, SLOT(syncMsgEvent(SyncMsg)));    
  5. QList listItemDatas;  
  6.  for (QList::iterator it=listItemDatas.begin(); it!=listItemDatas.end() ; ++it)  
  7.     {  
  8.         (*it)->colName;  
  9.     }  
  10. error: multiple types in one declaration 

自定義的類 {}后面沒有";"

還有一種可能是pro文件中引用了兩次單元文件;

expected unqualified-id before "int"前一句的";"誤寫為","

在Bulid工程時(shí),qmake *.pro死循環(huán),原因:pro文件里同一文件包含兩次;

char *const p ; p所指向的值不能變;

char cont *p; P所指向的地址不能變;

error: `nameLineEdt\\\' was not declared in this scope 函數(shù)域沒有寫; (函數(shù)域::函數(shù)名())ifdef/define重覆

  1. int main(int argc, char *argv[])  
  2. {  
  3.     Q_INIT_RESOURCE(qtdam);  
  4.       
  5.     QApplication app(argc, argv);  
  6.     QSplashScreen *splash = new QSplashScreen;  
  7.     QString path=app.applicationDirPath();  
  8.     IDIOMA *lang = new IDIOMA();  
  9.     lang->setfile_idioma(path+"/languages.lng");  
  10.     if (lang->idioma_seleccionado=="Español")  
  11.         splash->setPixmap(QPixmap(":/images/splash_espagnol.png"));  
  12.     else  
  13.         splash->setPixmap(QPixmap(":/images/splash.png"));  
  14.     splash->show();  
  15.     Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;  
  16.     splash->showMessage(lang->leer_idioma("1"),topRight, Qt::white);  
  17.     MainWindow mainWin;  
  18.     mainWin.show();  
  19.     splash->finish(&mainWin);  
  20.     delete splash;  
  21.     return app.exec();  

函數(shù)如果有返回值必須寫,否則有造成一些不確定的錯(cuò)誤,如:

  1. QString a()  
  2. {  
  3. }  
  4.  
  5. QString str;  
  6. str = "abc";  
  7. str.append(a());  
  8. QMessageBox::warning(this, tr("呼叫"),str,QMessageBox::Ok); 

上面的情況,對(duì)話框可以出來,但點(diǎn)擊對(duì)話框中的"確定"后,程序會(huì)死在那;

進(jìn)行信號(hào)連接時(shí),要確保連接參數(shù)中的對(duì)象已經(jīng)創(chuàng)建過,否則會(huì)報(bào)保護(hù)錯(cuò);

圖片加載不了,有可能是Qt庫(kù)中的插件庫(kù)沒有拷貝;

加載路徑指令:

  1. QCoreApplication::addLibraryPath(QObject::tr("%1%2plugins").arg(QCoreApplication::applicationDirPath()).arg("/")); 

qDebug() << "插件加載的路徑是(QCoreApplication::libraryPaths):" << QCoreApplication::libraryPaths()<        

有三個(gè)插件加載路徑 1,應(yīng)用程序路徑;2,QTDIR環(huán)境路徑,3,加入的路徑;     

  1. TRACE_LEVEL=5 TRACE_SUBSYS=DB /d/study/umpcapp/umpcapp-dev-1.0.0/debug/gpsapp.exe   
  2.  
  3.  void DragWidget::mousePressEvent(QMouseEvent *event)  
  4.  {  
  5.      QLabel *child = static_cast(childAt(event->pos()));  
  6.      if (!child)  
  7.          return;  
  8.  
  9.      QPixmap pixmap = *child->pixmap();  
  10.  
  11.      QByteArray itemData;  
  12.      QDataStream dataStream(&itemData, QIODevice::WriteOnly);  
  13.      dataStream << pixmap << QPoint(event->pos() - child->pos()); 

 
取得應(yīng)用程序所在路徑,注:結(jié)果后面未加"/"

  1. QCoreApplication::applicationDirPath() 

*.hpp文件,如果改動(dòng),Bulid后對(duì)改動(dòng)后代碼不起作用,必須ReBulid才可以;

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

責(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:44:25

Qt

2011-06-17 15:37:42

Qt

2011-06-17 14:54:31

Qt

2011-06-17 14:41:56

Qt

2011-06-17 14:12:32

Qt

2011-06-17 15:06:14

Qt

2011-06-17 15:32:28

Qt

2011-06-27 14:56:46

Qt Designer

2011-09-16 09:38:19

Emacs

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初步知識(shí)

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ù)棧公眾號(hào)