Why Does Qt Use Moc for Signals and Slots(QT官方的解释:GUI可以是动态的)
2016-07-23 06:30
627 查看
GUIs are Dynamic
C++ is a standarized, powerful and elaborate general-purpose language. It's the only language that is exploited on such a wide range of software projects, spanning every kind of application from entire operating systems, database servers and high end graphics applications to common desktop applications. One of the keys to C++'s success is its scalable language design that focuses on maximum performance and minimal memory consumption whilst still maintaining ANSI C compatibility.For all these advantages, there are some downsides. For C++, the static object model is a clear disadvantage over the dynamic messaging approach of Objective C when it comes to component-based graphical user interface programming. What's good for a high end database server or an operating system isn't necessarily the right design choice for a GUI frontend. With
moc, we have turned this disadvantage into an advantage, and added the flexibility required to meet the challenge of safe and efficient graphical user interface programming.
Our approach goes far beyond anything you can do with templates. For example, we can have object properties. And we can have overloaded signals and slots, which feels natural when programming in a language where overloads are a key concept. Our signals add zero bytes to the size of a class instance, which means we can add new signals without breaking binary compatibility.
Another benefit is that we can explore an object's signals and slots at runtime. We can establish connections using type-safe call-by-name, without having to know the exact types of the objects we are connecting. This is impossible with a template based solution. This kind of runtime introspection opens up new possibilities, for example GUIs that are generated and connected from Qt Designer's XML UI files.
http://doc.qt.io/qt-5/why-moc.html
相关文章推荐
- ST表与二分 (CodeForces 689D-Friends and Subsequences)
- UITableView的性能优化? 滑动的时候有种卡的感觉是为什么?怎么解决?
- Basic_Android关于buildToolVersion与CompileSdkVersion
- Cannot create PoolableConnectionFactory (Communications link failure due to underlying exception 解决
- 52. N-Queens II
- JSP页面中的request.getContextPath()报错问题
- UIAlertController的使用
- 【STL记录】Containers--Deques
- [LeetCode] Wiggle Subsequence 摆动子序列
- 2016ACM暑假集训 - 4 Values whose Sum is 0
- 【Leetcode】Wiggle Subsequence
- 51.In a system, large online transaction processing (OLTP) jobs run during the daytime that require
- MUI(4)
- iOS开发 iOS7显示偏差(UITableView下移)解决办法
- UIWindow
- requireJS 用法
- UVA 11538 Chess Queen
- 适配ios7的时候仿UIAlertView弹框效果,修改内部的label和button的属性
- UICollectionViewCell 3种创建方法
- Biee 迁移和刷新GUIDs