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)