Qt multiple inheritance, to put Qobject in the front, otherwise error--c++ think human nature is evil, the default is private, this and Delphi's worldview is not the same

Source: Internet
Author: User

On the basis of the purchased control (no source code), want to add some features of Qobject, have to inherit more:

Class Myprogress:public cprogress, public qobject

But always error:

Release\moc_my_tool.cpp:80:12:error: ' Qt_metacast ' is not a member of ' cprogress '
Return Cprogress::qt_metacast (_clname);

Clear temporary files, recompile a few times, still so, I thought that QT does not support the other class library based on multiple inheritance?

Later brainwave, may want to write qobject in the front, so Q_object macro will immediately unfold, and apply to follow the inheritance class, so change to this:

Class Myprogress:public Qobject, public cprogress

This is the time to compile the line.

Do not know is intentional, or unintentional, Qwidget also first inherit Qobject, and then inherit Qpaintdevice.

------------------------------------------------------------------

It is also noteworthy that, when inheriting, to write two public separately (alas, C + + thinks that human nature is evil, the default is private, this is not the same as the world view of Delphi), otherwise it will error, Some features of Qobject cannot be used for cprogress (such as the Connect function).

Qt multiple inheritance, to put Qobject in the front, otherwise error--c++ think human nature is evil, the default is private, this and Delphi's worldview is not the same

Related Article

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.