当前位置:网站首页>QT | event system qevent
QT | event system qevent
2022-07-24 23:07:00 【InfoQ】
Preface :
- Occurs when interacting with a user ( For example, press the mouse :mousePressEvent);
- It happens automatically ( Like timer events :timerEvent);
The handling of events :
- Method 1 : Re implement event functions .For example, re implement the paintEvent()、mousePressEvent() And so on . At this time, the most commonly used method , However, it can only be used to deal with specific events of specific parts .
- for example :void paintEvent(QPaintEvent *event);
- Method 2 : Re actualize notify() function .This function is very powerful , Provides complete control , You can get events before the event filter gets them . But it can only handle one event at a time .
- Method 3 : towards QApplication Object .Because a program has only one QApplication object , So the function and use of this realization notify() The function is the same , The advantage is that you can handle multiple events at the same time .
- Method four : Re actualize event() function .QObject Class event() Function can get the event before it reaches the default event handler function .
- for example :bool event(QEvent *event);
- Method five : Install the event filter on the object .Using event filters, you can handle different events of different subcomponents in one interface class at the same time .
- for example :bool eventFilter(QObject *obj, QEvent *event);
The transmission of events :
- stay paintEvent() At the end of the function, call :QWidget::paintEvent(event);
- stay event() At the end of the function, call :return QWidget::event(event);
- stay eventFilter() Call at the end of function :return QWidget::eventFilter(obj, event);
边栏推荐
- Archsummit: evolution of the underlying framework of cherished microservices
- 一文读懂Elephant Swap的LaaS方案的优势之处
- Cross entropy loss
- Filter list
- 【零基础】php代码审计之sql注入
- 中金证券新客理财产品收益可以达到百分之六?开户怎么开?
- Connector in C
- Some analysis of slow MySQL query
- Is the income of CICC securities' new financial products 6%? I want to open an account and manage money
- VGA display based on FPGA
猜你喜欢

Icassp 2022 | KS transformer for multimodal emotion recognition

IP first experiment hdcl encapsulates PPP, chap, mGRE

高阶产品如何提出有效解决方案?(1方法论+2案例+1清单)

The kettle job implementation runs a kettle conversion task every 6S

burp从溯源到反制思路

VGA display based on FPGA

Power consumption of chip

Notes of Teacher Li Hongyi's 2020 in-depth learning series lecture 1

The rule created by outlook mail is invalid. Possible reasons

Time series data in industrial Internet of things
随机推荐
凸优化基础知识
How to speculate on the Internet? Is it safe to speculate on mobile phones
Is it safe to log in the securities account on the flush
Baidu online disk +chrome plug-in
P3201 [hnoi2009] dream pudding heuristic merge
Connector in C
salesforce零基础学习(一百一十六)workflow -> flow浅谈
RichTextBox operation
IndexTree
郑慧娟:基于统一大市场的数据资产应用场景与评估方法研究
Notes of Teacher Li Hongyi's 2020 in-depth learning series 2
背景图和二维码合成
P3201 [HNOI2009] 梦幻布丁 启发式合并
解决JSP无法使用session.getAttribute()
The rule created by outlook mail is invalid. Possible reasons
Do you need to open an account to buy a wealth management product with a 6% income?
[cloud native kubernetes] kubernetes cluster advanced resource object staterulesets
Process / thread synchronization mechanism
Which securities account is the best and safest for beginners
Archsummit: evolution of the underlying framework of cherished microservices