久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Qt:插槽返回值的含義?

Qt: meaning of slot return value?(Qt:插槽返回值的含義?)
本文介紹了Qt:插槽返回值的含義?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

根據文檔,插槽的返回值沒有任何意義.
然而在生成的 moc 代碼中,我看到如果一個插槽返回一個值,這個值用于某些東西.知道它有什么作用嗎?

According to the documentation the return value from a slot doesn't mean anything.
Yet in the generated moc code I see that if a slot returns a value this value is used for something. Any idea what does it do?

這是我所談論的一個例子.這是取自 moc 生成的代碼.'message' 是一個不返回任何內容的槽,'selectPart' 被聲明為返回 int.

Here's an example of what I'm talking about. this is taken from code generated by moc. 'message' is a slot that doesn't return anything and 'selectPart' is declared as returning int.

case 7: message((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
case 8: { int _r = selectPart((*reinterpret_cast< AppObject*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])));
    if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; }  break;

推薦答案

返回值僅在您想將插槽作為普通成員函數調用時才有用:

The return value is only useful if you want to call the slot as a normal member function:

class MyClass : public QObject {
    Q_OBJECT
public:
    MyClass(QObject* parent);
    void Something();
public Q_SLOTS:
    int Other();
};

void MyClass::Something() {int res = this->Other();...}

void MyClass::Something() { int res = this->Other(); ... }

似乎這不是可以使用返回值的唯一方法,QMetaObject::invokeMethod 方法可用于調用插槽并獲取返回值.雖然看起來做起來有點復雜.

It seems that's not the only way the return value can be used, the QMetaObject::invokeMethod method can be used to call a slot and get a return value. Although it seems like it's a bit more complicated to do.

這篇關于Qt:插槽返回值的含義?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 中文字幕国产 | 天天干狠狠操 | 视频一区二区在线观看 | 成年女人免费v片 | 成人精品一区二区三区中文字幕 | 高清18麻豆 | 国产精品久久久久久久久久东京 | 成年免费大片黄在线观看一级 | 成人欧美一区二区三区黑人孕妇 | 免费a级毛片在线播放 | 99精品视频在线观看免费播放 | 91文字幕巨乱亚洲香蕉 | 国产亚洲精品精品国产亚洲综合 | 中文字幕第九页 | 在线午夜电影 | 天天天天操 | 欧美一级毛片免费观看 | 国产成人精品综合 | 精品久久久久久一区二区 | 91精品国产综合久久福利软件 | 中文字幕精品一区久久久久 | 欧美成人a | 欧美成年人网站 | 伊人久久综合 | 亚洲第一福利视频 | 自拍偷拍中文字幕 | 色视频网站 | 欧美视频成人 | 亚洲精品久久久久久下一站 | 欧美成人一区二区三区 | 天天干狠狠 | 爱草视频 | 日韩精品在线观看一区二区 | 久久一区二 | 免费毛片网站在线观看 | 成年人免费看的视频 | 国产精品中文字幕在线 | 成人性视频免费网站 | 草久久久 | 国产精品一区在线观看你懂的 | 精品久久久久香蕉网 |