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

Qt 事件和信號/插槽

Qt events and signal/slots(Qt 事件和信號/插槽)
本文介紹了Qt 事件和信號/插槽的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

在Qt世界中,事件和信號/插槽有什么區(qū)別?

In the Qt world, what is the difference of events and signal/slots?

一個(gè)會取代另一個(gè)嗎?事件是信號/槽的抽象嗎?

Does one replace the other? Are events an abstraction of signal/slots?

推薦答案

Qt 文檔 可能解釋得最好:

在Qt中,事件是對象,派生的來自抽象的 QEvent 類,即代表已經(jīng)發(fā)生的事情無論是在應(yīng)用程序中還是作為外部活動的結(jié)果應(yīng)用程序需要了解.事件可以被接收和處理QObject 子類的任何實(shí)例,但它們與小部件.本文檔描述了如何事件在一個(gè)典型應(yīng)用.

In Qt, events are objects, derived from the abstract QEvent class, that represent things that have happened either within an application or as a result of outside activity that the application needs to know about. Events can be received and handled by any instance of a QObject subclass, but they are especially relevant to widgets. This document describes how events are delivered and handled in a typical application.

所以事件和信號/槽是完成相同事情的兩個(gè)并行機(jī)制.通常,一個(gè)事件將由外部實(shí)體(例如,鍵盤或鼠標(biāo)滾輪)生成,并通過 QApplication 中的事件循環(huán)傳遞.通常,除非您設(shè)置代碼,否則您不會生成事件.您可以通過 QObject::installEventFilter() 過濾它們或通過覆蓋適當(dāng)?shù)暮瘮?shù)來處理子類對象中的事件.

So events and signal/slots are two parallel mechanisms accomplishing the same things. In general, an event will be generated by an outside entity (for example, keyboard or mouse wheel) and will be delivered through the event loop in QApplication. In general, unless you set up the code, you will not be generating events. You might filter them through QObject::installEventFilter() or handle events in subclassed object by overriding the appropriate functions.

信號和插槽更容易生成和接收,您可以連接任意兩個(gè) QObject 子類.它們是通過元類處理的(更多信息請查看您的 moc_classname.cpp 文件),但是您將生成的大多數(shù)類間通信可能會使用信號和槽.信號可以立即傳遞或通過隊(duì)列延遲傳遞(如果您使用線程).

Signals and Slots are much easier to generate and receive and you can connect any two QObject subclasses. They are handled through the Metaclass (have a look at your moc_classname.cpp file for more), but most of the interclass communication that you will produce will probably use signals and slots. Signals can get delivered immediately or deferred via a queue (if you are using threads).

可以生成信號.

這篇關(guān)于Qt 事件和信號/插槽的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數(shù)據(jù)?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環(huán): for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環(huán)?)
Reusing thread in loop c++(在循環(huán) C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環(huán)形?)
主站蜘蛛池模板: 免费成人高清在线视频 | 午夜免费视频 | 中文字幕 国产精品 | 99视频免费看| www.99久久.com| 日日摸日日爽 | 亚洲精品久久久久久久久久久 | 国产一区 | 亚洲精品视频免费观看 | 欧美亚洲国产一区二区三区 | 国产一级片91 | 久久久女女女女999久久 | 操人网站| 亚洲美女在线视频 | 国产在线麻豆精品入口 | 美女操网站 | 久草色播 | 欧美成人一区二区三区片免费 | 久久99国产精品 | 亚洲少妇综合网 | 成人教育av | 成人精品鲁一区一区二区 | 日韩一区二区三区四区五区 | 91中文视频 | www.4hu影院 | 青春草国产 | 日韩视频国产 | a级黄色毛片免费播放视频 国产精品视频在线观看 | 一级黄色av电影 | 精品av天堂毛片久久久借种 | 亚洲视频在线一区 | 先锋资源吧 | 真人女人一级毛片免费播放 | 色伊人| 久久亚洲国产精品日日av夜夜 | 中文av字幕 | 成人国产在线观看 | 亚洲精品在线免费 | 色婷婷精品久久二区二区蜜臂av | 狠狠操你 | 四季久久免费一区二区三区四区 |