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

Qt 事件和信號/插槽

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

問題描述

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

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

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

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

推薦答案

Qt 文檔 可能解釋得最好:

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

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.

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

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.

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

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).

可以生成信號.

這篇關于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 ()?環形?)
主站蜘蛛池模板: 看一级毛片视频 | 中文字幕在线一区二区三区 | 欧美一级特黄aaa大片在线观看 | 欧美福利在线 | 日韩国产一区二区三区 | 999久久久国产精品 欧美成人h版在线观看 | 欧美日韩国产一区二区三区 | 日韩高清一区 | 五月天国产视频 | 午夜视频免费网站 | 小视频你懂得 | 日本精品一区二区三区在线观看 | 久久av一区二区三区 | 亚洲黄色av | www.99精品 | 久久国产精品免费视频 | 中文字幕电影在线观看 | 国产一级一级 | 久久午夜视频 | 国产精品久久久久久网站 | 欧美一级黑人aaaaaaa做受 | 日本在线免费看最新的电影 | 一级美国黄色片 | 狠狠操av | 密室大逃脱第六季大神版在线观看 | 亚洲精品9999久久久久 | 一级片在线播放 | 久久精品国产一区二区三区不卡 | 成人精品一区 | 成人亚洲视频 | 欧美aaaaaaaaaa| 人人爽日日躁夜夜躁尤物 | 欧美亚洲综合久久 | 日本欧美在线 | 日日夜夜草| 久久国产视频播放 | 精品三级在线观看 | 欧美成人激情 | av一区二区三区四区 | 成人在线视频网 | 九九热精品视频 |