现在的位置: 首页 > 综合 > 正文

Chapter 4: Using Custom Property Types

2013年03月02日 ⁄ 综合 ⁄ 共 761字 ⁄ 字号 评论关闭

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]

抱歉!评论已关闭.