freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

qt的對象模型與信號槽的概念(已修改)

2025-03-03 00:22 本頁面
 

【正文】 . Qt的對象模型 和信號槽 的概念 Qt in Education This work is a Chinese translation of the original Qt Educational Training Materials published by Nokia: 169。 2023 Nokia Corporation and its Subsidiary(ies). Nokia, Qt and the Nokia and Qt logos are the registered trademarks of Nokia Corporation in Finland and other countries worldwide. This translation was created by Communication and Computer Network Laboratory of Guangdong Province, South China University of Technology. 169。 2023 Communication and Computer Network Laboratory of Guangdong Province, South China University of Technology. The enclosed Qt Educational Training Materials are provided under the Creative Commons AttributionNonCommercialShare Alike License Agreement. The full license text is available here: . 此文檔內(nèi)容是由諾基亞公司發(fā)布的原創(chuàng) Qt教育培訓(xùn)文檔的中文翻譯: 169。 2023諾基亞公司及其附屬公司。 Nokia (諾基亞 ), Qt以及 Nokia與 Qt商標(biāo)是 Nokia公司在芬蘭和全球其他國家的注冊商標(biāo)。 該翻譯版本由 華南理工大學(xué)廣東省計(jì)算機(jī)網(wǎng)絡(luò)重點(diǎn)實(shí)驗(yàn)室 創(chuàng)造。 169。 2023 華南理工大學(xué)廣東省計(jì)算機(jī)網(wǎng)絡(luò)重點(diǎn)實(shí)驗(yàn)室 本 Qt 教育培訓(xùn)材料依照署名 非商業(yè)性使用 相同方式共享 ( Creative Commons AttributionNonCommercialShare Alike License Agreement)發(fā)布。 完整的許可證文本可以在這里找到: .。 QObject類 ? QObject是幾乎所有 Qt類和所有部件 (widget)的基類。 ? 它包含很多組成 Qt的機(jī)制 ? 事件 ? 信號和槽 ? 屬性 ? 內(nèi)存管理 QObject類 ? QObject 是大部分 Qt 類的基類 例外的例子是 : ? 類需要作為輕量級的類,例如圖元( graphical primitives)。 ? 數(shù)據(jù)容器 (QString, QList, QChar等 ) ? 需要可復(fù)制的類,因?yàn)?QObject類是無法被復(fù)制的。 QObject類 ? 它們可以擁有一個(gè)名字 (QObject::objectName) ? 它們被放置在 QObject實(shí)例的一個(gè)層次上 ? 它們可以有到其他 QObject 實(shí)例的聯(lián)接 ? 例子 : 在運(yùn)行時(shí)復(fù)制一個(gè)部件有意義嗎 ? “QObject 的實(shí)例是單獨(dú)的 !” 元數(shù)據(jù)( Meta data) ? Qt用 C++實(shí)現(xiàn)內(nèi)省 ? 每一個(gè) QObject 都有一個(gè)元對象 ? 元對象涉及: ? 類名 (QObject::className) ? 繼承 (QObject::inherits) ? 屬性 ? 信號和槽 ? 普通信息 (QObject::classInfo) 元數(shù)據(jù) ? 元數(shù)據(jù)通過元對象編譯器 (moc)在編譯時(shí)組合在一起。 sources *.cpp executables object files *.o headers *.h 普通的 C++生成過程 includes piles links 元數(shù)據(jù) Meta data ? 元數(shù)據(jù)通過元對象編譯器 (moc)在編譯時(shí)組合在一起。 ? moc從頭文件里面獲得數(shù)據(jù)。 sources *.cpp executables object files *.o headers *.h generated moc_*.cpp Qt C++ 生成過程 includes piles links piles mocs 元數(shù)據(jù) ? moc 找什么? class MyClass : public QObject { Q_OBJECT Q_CLASSINFO(author, John Doe) public: MyClass(const Foo foo, QObject *parent=0)。 Foo foo() const。 public slots: void setFoo( const Foo foo )。 signals: void fooChanged( Foo )。 private: Foo m_foo。 }。 Qt 關(guān)鍵字 類的一般信息 Q_OBJECT 宏 , 通常是第一步 首先確認(rèn)該類繼承自 Qobject (可能是間接 ) 內(nèi)省 (Introspection) ? 類在運(yùn)行時(shí)了解它們自己的信息 ? 對實(shí)現(xiàn)腳本和動(dòng)態(tài)語言的綁定 有很好的支持。 if (objectinherits(QAbstractItemView)) { QAbstractItemView *view = static_castQAbstractItemView*(widget)。 view... enum CapitalsEnum { Oslo, Helsinki, Stockholm, Copenhagen }。 int index = objectmetaObject()indexOfEnumerator(CapitalsEnum)。 objectmetaObject()enumerator(index)key(objectcapital())。 能夠?qū)崿F(xiàn)動(dòng)態(tài)轉(zhuǎn)換而不需要運(yùn)行時(shí)類型檢查 ( RTTI) 例子 :它可以將枚舉值轉(zhuǎn)換成更容易閱讀和保存的字符串 元對象了解細(xì)節(jié) 屬性 (Properties) ? QObject有 getter和 setter函數(shù)屬性 ? 命名策略 : color, setColor ? 對于布爾 : isEnabled, setEnabled class QLabel : public QFrame { Q_OBJECT Q_PROPERTY(QString text READ text WRITE setText) public: QString text() const。 public slots: void setText(const QString )。 }。 Setter, 返回空 , 將值當(dāng)成唯一參數(shù) Getter, 常量 ,返回值 , 沒有參數(shù) 屬性 ? 為什么使用 setter 函數(shù)? ? 可以驗(yàn)證設(shè)置 ? 對可能的變化作出反應(yīng) void setMin( int newMin ) { if( newMin m_max ) { qWarning(Ignoring setMin(%d) as min max., newMin)。 return。 } ... void setMin( int newMin ) { ... m_min = newMin。 updateMinimum()。 } 屬性 Properties ? 為什么使用 getter 函數(shù)? ? 間接的屬性 QSize size() const { return m_size。 } int width() const { return ()。 } 屬性 Q_PROPERTY(type name READ getFunction [WRITE setFunction] [RESET resetFunction] [NOTIFY notifySignal] [DESIGNABLE bool] [SCRIPTABLE bool] [STORED bool] [USER bool] [CONSTANT] [FINAL]) 使用屬性 ? 直接獲取 ? 通過元信息和屬性系統(tǒng) ? 在運(yùn)行時(shí)發(fā)現(xiàn)屬性 QString text = labeltext()。 labelsetText(Hello World!)。 QString text = objectproperty(text).toString()。 objectsetProperty(text, Hello World)。 int QMetaObject::propertyCount(
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
公安備案圖鄂ICP備17016276號-1