Why Does QT used Moc for signals and Slots (QT official explanation: GUI can be dynamic)

Source: Internet
Author: User

GUIs is Dynamic

C + + is a standarized, powerful and elaborate general-purpose language. It's the only language that's exploited on such a wide range of software projects, spanning every kind of application fro M 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 this focuses on maximum performance and minimal memory Co Nsumption whilst still maintaining ANSI C compatibility.

For all these advantages, there is 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 fron Tend. With moc , we had turned this disadvantage into a advantage, and added the flexibility required to meet the challenge O F Safe and efficient graphical user interface programming.

Our approach goes far beyond anything you can does 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 is 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 com Patibility.

Another benefit is so we can explore an object ' s signals and slots at runtime. We can establish connections using Type-safe call-by-name, without have to know the exact types of the objects we is Co Nnecting. This is impossible with a template based solution. This kind of the runtime introspection opens up new possibilities, for example GUIs that is generated and connected from Qt D Esigner ' s XML UI files.

Http://doc.qt.io/qt-5/why-moc.html

Why Does QT used Moc for signals and Slots (QT official explanation: GUI can be dynamic)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.