Analysis on Qt Object Model

Source: Internet
Author: User

This article mainly introducesQt Object ModelIt has many features. Now let's get to know it first. See the content.

Qt Object Model

Standard C ++Object ModelIt provides a very effective operation time to support object examples. However, its static nature is not flexible enough in some problematic areas. Graphic user interface programming is a field that requires both time efficiency and high flexibility.QtBy combining the speed andQt Object ModelFlexibility to provide.

QtAdded the following features to C ++:

A powerful mechanism called signal and slot for seamless object communication.

Queryable and design object attributes

Powerful event and event Filters

International string Translation Based on Context

The well-developed time interval-driven timer makes it possible to integrate multiple tasks in an event-driven graphical interface.

Organizes hierarchical and queryable object trees of object ownership in a natural way

The QPointer is automatically set to 0 when the reference object is destroyed, unlike normal C ++ pointers, they become wild pointers when their objects are destroyed.

Dynamic computing based on database boundaries

Many of these Qt features are implemented through the standard C ++ technology and inherited based on QObject. Others, such as object communication mechanisms and dynamic systems, need to be provided by Qt's own metadatabase Compiler (moc.

The meta-Object System is a C ++ extension that makes this language more suitable for real component GUI programming. Although templates can also be used to expand C ++, the meta-Object System provides benefits that cannot be achieved through standard C ++ templates; see why Qt does not use a template to implement signals and slots?

Qt object: ID vs Value

Many ofQt Object ModelThe added feature requires us to regard the object as an identity, not a value. Values can be copied and given; identities can be cloned. Cloning means creating a new identity instead of copying an old identity. For example, twins have different identities. They may look the same, but they have different names, locations, and social circles.

Cloning an identity is a copy of a value or a complex operation. We canQt Object ModelSee what this actually means.

A Qt object...

There may be a unique QObject: objectName (). If we copyQtObject. What name should we copy to this object?

There is a position in an object hierarchy. If we copyQtYes. Where should I store this copy?

It can be used with otherQtObjects are connected to them to transmit objects or receive signals from them. If we copyQtObject, how do we pass these connections to this copy?

You can add new properties not declared in the C ++ class to it at runtime. If we copyQtObject. Should this copy contain the new nature we added to the original object?

For these reasons,QtThe object should be treated as an identity, not a value. Identity can be cloned, but cannot be copied or the specified size, and cloning an identity is much more complicated than copying or specifying a value. Therefore, the copying constructor and Allocation Operations of QObject and all QObject sub-classes (either directly or indirectly) are invalid ..

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.