How to integrate a custom GraphicsItem into a QML scene?
问题 Assume you have created the following custom QGraphicsRectItem in C++: class MyCustomItem : public QGraphicsRectItem { public: MyCustomItem(MyCustomItem* a_Parent = 0); virtual ~MyCustomItem(); // specific methods private: // specific data }; Assume also that you have defined in a QML script an ApplicationWindow : // main.qml import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.0 ApplicationWindow { id: myWindow title: qsTr("My Window") width: 640 height: 480 visible: true }