aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/extending/chapter1-basics
diff options
context:
space:
mode:
authorDamian Jansen <damian.jansen@nokia.com>2011-08-30 16:18:20 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-05 03:09:09 +0200
commit76dd4f8af9c48a685cb50bfa02389b392bc12a5a (patch)
tree959044545ec8b8b5d6ef40489c02d4885d4ec619 /examples/declarative/tutorials/extending/chapter1-basics
parentf22ae0f5f18a354bf3addd8023ad8b8810e42bac (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/chapter1-basics')
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/app.qml2
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro2
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/main.cpp6
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp10
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/piechart.h8
5 files changed, 13 insertions, 15 deletions
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml
index f42ec1e8fc..92dd147bab 100644
--- a/examples/declarative/tutorials/extending/chapter1-basics/app.qml
+++ b/examples/declarative/tutorials/extending/chapter1-basics/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/chapter1-basics/chapter1-basics.pro b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
index 77cc4cdfca..0f0416718c 100644
--- a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
+++ b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
@@ -1,4 +1,4 @@
-QT += declarative qtquick1
+QT += declarative
HEADERS += piechart.h
SOURCES += piechart.cpp \
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp
index 2ab2e2b8b9..4c11768e18 100644
--- a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp
+++ b/examples/declarative/tutorials/extending/chapter1-basics/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/chapter1-basics/piechart.cpp b/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp
index bfc1645f57..5820c5626c 100644
--- a/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp
+++ b/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp
@@ -41,11 +41,9 @@
#include <QPainter>
//![0]
-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);
}
//![0]
@@ -70,11 +68,11 @@ void PieChart::setColor(const QColor &color)
}
//![1]
-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);
}
//![1]
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/piechart.h b/examples/declarative/tutorials/extending/chapter1-basics/piechart.h
index c873f6a780..a5afec5252 100644
--- a/examples/declarative/tutorials/extending/chapter1-basics/piechart.h
+++ b/examples/declarative/tutorials/extending/chapter1-basics/piechart.h
@@ -41,17 +41,17 @@
#define PIECHART_H
//![0]
-#include <QDeclarativeItem>
+#include <QtDeclarative/QSGPaintedItem>
#include <QColor>
-class PieChart : public QDeclarativeItem
+class PieChart : public QSGPaintedItem
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QColor color READ color WRITE setColor)
public:
- PieChart(QDeclarativeItem *parent = 0);
+ PieChart(QSGItem *parent = 0);
QString name() const;
void setName(const QString &name);
@@ -59,7 +59,7 @@ public:
QColor color() const;
void setColor(const QColor &color);
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ void paint(QPainter *painter);
private:
QString m_name;