Qt信号和插槽的效率 [英] Efficiency of Qt Signals and Slots

查看:602
本文介绍了Qt信号和插槽的效率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览QMainWindow中的方法,并注意到一些部分(例如resizeEvent和winEvent)不是作为信号实现的,而是你必须继承这个类才能覆盖它们。

I was browsing the methods inside of QMainWindow and noticed that some parts (such as resizeEvent and winEvent) are not implemented as signals but rather you have to inherit this class to be able to override them.

我的问题是,信号和槽的有效性,并且可以实现这些类型的函数作为其他类可以订阅的信号。例如,在高性能游戏引擎内部。

My question is, how efficient are signals and slots and would it be possible to implement these types of functions as signals from which other classes can subscribe to. For instance, inside of a high performance game engine.

推荐答案

从我记得,Trolltech说,比虚拟调用慢约10倍。您应该能够轻松处理几十个,即使不是每秒数十万个信号。

From what I recall, Trolltech stated that a signal/slot call is about 10 times slower than a virtual call. You should be able to easily process tens, if not hundreds of thousands signals per second.

这篇关于Qt信号和插槽的效率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆