diff options
author | Damian Jansen <damian.jansen@nokia.com> | 2011-08-30 16:18:20 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-09-05 03:09:09 +0200 |
commit | 76dd4f8af9c48a685cb50bfa02389b392bc12a5a (patch) | |
tree | 959044545ec8b8b5d6ef40489c02d4885d4ec619 /examples/declarative/tutorials/extending/chapter2-methods | |
parent | f22ae0f5f18a354bf3addd8023ad8b8810e42bac (diff) |
Update extension tutorials and examples to QtQuick2
Also add missing licence header and update example tests
Change-Id: Ic2dc8c893ddf22f646eaeba86b6f3b4a2772726c
Reviewed-on: http://codereview.qt.nokia.com/3844
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
Diffstat (limited to 'examples/declarative/tutorials/extending/chapter2-methods')
5 files changed, 13 insertions, 16 deletions
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/app.qml b/examples/declarative/tutorials/extending/chapter2-methods/app.qml index e2f34c7f7b..05f5952fd6 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/app.qml +++ b/examples/declarative/tutorials/extending/chapter2-methods/app.qml @@ -39,7 +39,7 @@ ****************************************************************************/ //![0] import Charts 1.0 -import QtQuick 1.0 +import QtQuick 2.0 Item { width: 300; height: 200 diff --git a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro index 77cc4cdfca..0f0416718c 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro +++ b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro @@ -1,4 +1,4 @@ -QT += declarative qtquick1 +QT += declarative HEADERS += piechart.h SOURCES += piechart.cpp \ diff --git a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp index 2ab2e2b8b9..4c11768e18 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp +++ b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp @@ -39,8 +39,7 @@ ****************************************************************************/ //![0] #include "piechart.h" -#include <qdeclarative.h> -#include <QDeclarativeView> +#include <QSGView> #include <QApplication> int main(int argc, char *argv[]) @@ -49,7 +48,8 @@ int main(int argc, char *argv[]) qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart"); - QDeclarativeView view; + QSGView view; + view.setResizeMode(QSGView::SizeRootObjectToView); view.setSource(QUrl::fromLocalFile("app.qml")); view.show(); return app.exec(); diff --git a/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp b/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp index 78970e536f..86407f1f17 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp +++ b/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp @@ -39,13 +39,10 @@ ****************************************************************************/ #include "piechart.h" #include <QPainter> -#include <QDebug> -PieChart::PieChart(QDeclarativeItem *parent) - : QDeclarativeItem(parent) +PieChart::PieChart(QSGItem *parent) + : QSGPaintedItem(parent) { - // need to disable this flag to draw inside a QDeclarativeItem - setFlag(QGraphicsItem::ItemHasNoContents, false); } QString PieChart::name() const @@ -68,11 +65,11 @@ void PieChart::setColor(const QColor &color) m_color = color; } -void PieChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +void PieChart::paint(QPainter *painter) { QPen pen(m_color, 2); painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); painter->drawPie(boundingRect(), 90 * 16, 290 * 16); } diff --git a/examples/declarative/tutorials/extending/chapter2-methods/piechart.h b/examples/declarative/tutorials/extending/chapter2-methods/piechart.h index bfcbd80ab1..38f5c0553f 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/piechart.h +++ b/examples/declarative/tutorials/extending/chapter2-methods/piechart.h @@ -40,11 +40,11 @@ #ifndef PIECHART_H #define PIECHART_H -#include <QDeclarativeItem> +#include <QtDeclarative/QSGPaintedItem> #include <QColor> //![0] -class PieChart : public QDeclarativeItem +class PieChart : public QSGPaintedItem { //![0] Q_OBJECT @@ -55,7 +55,7 @@ class PieChart : public QDeclarativeItem public: //![1] - PieChart(QDeclarativeItem *parent = 0); + PieChart(QSGItem *parent = 0); QString name() const; void setName(const QString &name); @@ -63,7 +63,7 @@ public: QColor color() const; void setColor(const QColor &color); - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + void paint(QPainter *painter); //![2] Q_INVOKABLE void clearChart(); |