Chapter 4: Using Custom Property Types

http://doc.qt.nokia.com/4.7-snapshot/declarative-tutorials-extending-chapter4-custompropertytypes.html

We can also use various other property types. QML has built-in support for the types listed in the QML Basic Types documentation, which includes the following:

If we want to create a property whose type is not supported by QML by default, we need to register the type with QML.

 

要点:

改为PieSlice 画图,PieChart不可视。

Like PieChart, this new PieSlice type inherits from QDeclarativeItem and declares its properties with Q_PROPERTY():

 

Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice)

 

 

//![0]
void PieChart::setPieSlice(PieSlice *pieSlice)
{
    m_pieSlice = pieSlice;
    pieSlice->setParentItem(this);
}
//![0]

你可能感兴趣的:(property)