Qt graphic item Diary

Source: Internet
Author: User

Today, when we use graphic view to add graphic items, we need to introduce a context menu. Naturally, we need to perform slot processing on the actions on the context menu, but graphic item is not inherited from qobject, therefore, multiple inheritance is required, and a new Inheritance of qobject is added. All modifications involving qobject are required to re-create qmake, because re-construct the meta file is not a problem at this time, after doing well, the problem arises, saying that the meta file contains a series of errors. In the past, QT required the qobject to be placed in the first place during multi-inheritance. After modification, it can be compiled, however, it will give a warning and continue tracking. In the past, graphic view provided a graphic object to replace the structure of graphic item + qobject, after a round of hard work, the problem can be solved in this simple way. In many cases, the problem is solved by knowing it, knowing it, not knowing it, or making logical speculation. The less the system is, the more application-oriented things have such characteristics. The more detailed the knowledge points are.

After these steps are completed, you can compile the code and run it to find a crash bug. It seems that there is a problem with the pointer of graphic object. Considering that the reinterpret_cast operation in one place is suspicious, this is true after Google. It is best to use dynamic_cast in the case of polymorphism. After the change, it will be OK.


Qt graphic item Diary

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.