Chapter 1: Creating a New Type

http://doc.qt.nokia.com/4.7-snapshot/declarative-tutorials-extending-chapter1-basics.html

 

-------------------------------------------------

笔记:

QML 各个Element对应的c++类(http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeelements.html):

Item instantiates the C++ class QDeclarativeItem

Component instantiates the C++ class QDeclarativeComponent

QtObject instantiates the C++ class QObject

 

 

要点:

PieChart::PieChart(QDeclarativeItem *parent) :

    QDeclarativeItem(parent)
{
    // need to disable this flag to draw inside a QDeclarativeItem
    setFlag(QGraphicsItem::ItemHasNoContents, false);
}

 

qmlRegisterType<PieChart>("com.mycompany.Charts", 1, 0, "PieChart");


 

import com.mycompany.Charts 1.0

posted on 2011-11-03 16:57  katago  阅读(218)  评论(0编辑  收藏  举报