成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Qt 編程點滴 初學者必看 (9)

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

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

QString怎么轉換成char

  1. QString str ="123456";  
  2. str.toAscii().data(); //this return a char* or const char*  
  3. str.toAscii() return a QByteArray  
  4.  
  5. QString Str; //Str = "asdfasdfasdf";  
  6. Str->toString().c_str(); 

調用 Q_DECLARE_METATYPE  報以下錯

  1. ..\..\..\..\Qt\src\corelib\kernel\qmetatype.h||In function \\\'void* qMetaTypeConstructHelper(const T*) [with T = ContactsInfoTabItemData]\\\':|  
  2. ..\..\..\..\Qt\src\corelib\kernel\qmetatype.h|152|instantiated from \\\'int qRegisterMetaType(const char*, T*) [with T = ContactsInfoTabItemData]\\\'|  
  3. src\contactsinfotabitemdata.h|62|instantiated from here|  
  4. ..\..\..\..\Qt\src\corelib\kernel\qmetatype.h|126|error: no matching function for call to \\\'ContactsInfoTabItemData::ContactsInfoTabItemData()\\\'| 

如果報以上相類似的錯誤,請對構造函數中的每個參數賦初值,下面的寫法是錯誤的

  1. class ContactsInfoTabItemData  
  2. {  
  3. public:  
  4.   ContactsInfoTabItemData(QString name,QString caption);  
  5. };  
  6. Q_DECLARE_METATYPE(ContactsInfoTabItemData); 

正確的寫法應為:

  1. class ContactsInfoTabItemData  
  2. {  
  3. public:  
  4.   ContactsInfoTabItemData(QString name=QString(),QString caption=QString());  
  5. };  
  6. Q_DECLARE_METATYPE(ContactsInfoTabItemData); 

如果程序莫名奇妙的退出,也不報DLL找不到的錯誤,請仔細檢查Main函數體有沒直接Return的語句,以造成不提示,直接退出的錯誤;

在Qt中計算文本的寬度與高度  ( http://www.cuteqt.com/blog/?p=1029 )

  1. error: incomplete type %u2018nsIDOMComment%u2019 used in nested name specifier 

產生此錯誤的原因:

  1.   g++ gives this message if you\\\'ve forward-declared a type, like this  
  2. class MyClass;  
  3. and then you try and access one of its members, like maybe:  
  4. MyClass::doSomething()  
  5. g++ is complaining that it hasn\\\'t seen the body of class MyClass yet, so it has no way to know what MyClass::doSomething is.  
  6. (In C++ jargon, an "incomplete type" is a type that\\\'s been forward-declared but not yet defined.) 

互斥用法:

  1. QMutex mutex;  
  2.  
  3. void GlobalVar::setUserInfo(const GlobalVar::UserInfo &userInfo)  
  4. {  
  5.     QMutexLocker locker(&mutex);  
  6.     this->userinfo = userInfo;  

自定義事件方法:

  1. a.h:  
  2.  
  3. #include "event.h"  
  4.  
  5. typedef void ( EventDelegater::*SetWidgetParent )(QWidget*,QString  );  
  6.  
  7. class test  
  8. {  
  9. public:  
  10.   Event OnSetWidgetParent;  
  11.  
  12. private:  
  13.   inline void invokeSetWidgetParent(QWidget *parentWidget,QString widgetName);    
  14. };  
  15.  
  16. a.cpp:  
  17.  
  18. inline void test::invokeSetWidgetParent(QWidget *parentWidget,QString widgetName)  
  19. {  
  20.  
  21.     if ( !OnSetWidgetParent.m_EventList.empty() )  
  22.     {  
  23.         // 循環事件列表  
  24.         Event< SetWidgetParent >::EventIterator iter;  
  25.         for ( iter = OnSetWidgetParent.m_EventList.begin();  
  26.                 iter != OnSetWidgetParent.m_EventList.end();  
  27.                 ++iter )  
  28.         {  
  29.             // 調用事件  
  30.             InvokeEvent( parentWidget, widgetName );  
  31.  
  32.         }  
  33.     }  

觸發事件:

  1. invokeSetWidgetParent(NULL,QString());   

綁定事件方法:

  1. test->OnSetWidgetParent.Bind(this, &MainWindow::setWidgetParent);   

 
自定義宏的用法:

  1. *.pro  
  2. DEBUGSAVETOFILE = 1 
  3. isEmpty(DEBUGSAVETOFILE){  
  4.     win32:debug {  
  5.         CONFIG += console  
  6.     }  
  7. }  
  8. else{  
  9.     DEFINES += __DEBUGSAVETOFILE__  
  10. }    
  11. main.cpp:  
  12. #ifdef __DEBUGSAVETOFILE__  
  13. #pragma message( "__DEBUGSAVETOFILE__ is defined.")  
  14.     qInstallMsgHandler( messageOutput );  
  15. #else  
  16. #pragma message("win32:debug is defined.")  
  17. #endif 

小結:本文主要介紹了在Qt 事件的使用,通過Qt 編程點滴介紹,也給自己提高了編程過程中需要注意的細節問題,由于本話題是一節一節為大家展現的,所以更多內容,請看編輯推薦。

責任編輯:zhaolei 來源: 互聯網
相關推薦

2011-06-17 14:12:32

Qt

2011-06-17 15:06:14

Qt

2011-06-17 15:32:28

Qt

2011-06-17 14:29:55

Qt

2011-06-17 14:41:56

Qt

2011-06-17 15:19:28

Qt

2011-06-17 15:25:18

Qt

2011-06-17 15:44:25

Qt

2011-06-17 14:54:31

Qt

2011-09-16 09:38:19

Emacs

2011-06-27 14:56:46

Qt Designer

2011-09-08 10:38:37

Widget

2011-08-24 17:05:01

Lua

2013-04-23 10:51:15

Linux壓縮

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

2009-11-17 15:33:26

PHP數組元素

2009-10-22 16:46:03

VB.NET初步知識

2009-11-23 10:29:43

CISCO路由器教程
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产成人一区二区三区电影 | 欧美在线成人影院 | 久久国色| 在线色网站 | 在线一区二区三区 | 国产精品一区二 | 天天天天操 | 人人干人人超 | 久久久99精品免费观看 | 中文字幕国产高清 | 在线观看三级av | 日本成人综合 | 午夜精品久久久久久久 | 一级大片免费 | 亚洲一区av| 亚洲品质自拍视频网站 | 国产精品成人一区二区三区 | 午夜激情影院 | 色久电影 | 国产亚洲精品久久yy50 | 欧美另类日韩 | 日韩欧美国产精品 | 亚洲高清网 | 户外露出一区二区三区 | 91人人在线 | 人妖videosex高潮另类 | 国产成人精品高清久久 | 国产精品一区二区在线 | 久久久久久久夜 | 亚洲福利视频一区二区 | 久久亚洲二区 | 久久久一区二区三区 | 亚洲狠狠爱 | 国产精品入口久久 | 干狠狠| 精品欧美乱码久久久久久1区2区 | 欧美日韩在线免费观看 | 超碰97免费在线 | 日韩视频―中文字幕 | 搞黄网站在线观看 | 精品亚洲一区二区 |