2024年3月13日发(作者:)

class CustomItem : public QGraphicsItem

{

public:

enum { Type = UserType + 1 };

int type() const override

{

// Enable the use of qgraphicsitem_cast with this item.

return Type;

}

...

};

qvariant_cast QVariant类型转换为实际的类型

Returns the given value converted to the template type T.

This function is equivalent to ().

等等...