aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/extending/chapter4-customPropertyTypes
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-09-12 08:12:58 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-09-12 08:12:58 +0200
commitd77218522eb480c8d528de18049cd7b604cdeb2a (patch)
treea6433a8e9205a95006eae10b53285a0e3487423d /examples/declarative/tutorials/extending/chapter4-customPropertyTypes
parent589c8445e2623ef8e0b8294d7c558a2948b2a5e3 (diff)
parentd5686fa2ac2248d5a31237573fa08697f18f035f (diff)
Merge branch 'master' into refactor
Conflicts: examples/declarative/cppextensions/qwidgets/qwidgets.pro examples/declarative/minehunt/main.cpp examples/declarative/minehunt/minehunt.pro src/declarative/items/context2d/qsgcontext2d.cpp src/declarative/items/qsgflickable.cpp src/declarative/items/qsgtextedit.cpp src/declarative/items/qsgtextinput.cpp src/declarative/particles/qsgangleddirection.cpp src/declarative/particles/qsgcumulativedirection.cpp src/declarative/particles/qsgcumulativedirection_p.h src/declarative/particles/qsgfollowemitter.cpp src/declarative/particles/qsgmodelparticle.cpp src/declarative/particles/qsgparticlesystem.cpp src/qtquick1/util/qdeclarativeview.h tests/auto/declarative/examples/examples.pro tests/auto/declarative/qsgfocusscope/tst_qsgfocusscope.cpp Change-Id: Ib4be2a5e742dee1a399d73da97161736f77448e5
Diffstat (limited to 'examples/declarative/tutorials/extending/chapter4-customPropertyTypes')
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml2
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro2
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp6
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp6
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h6
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp10
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h8
7 files changed, 18 insertions, 22 deletions
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
index 187095a769..68f667a812 100644
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/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/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
index 9942ccd0a9..c3f5402aea 100644
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
@@ -1,4 +1,4 @@
-QT += declarative qtquick1
+QT += declarative
HEADERS += piechart.h \
pieslice.h
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp
index dcb3481ac1..1113cc55cb 100644
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp
@@ -40,8 +40,7 @@
#include "piechart.h"
#include "pieslice.h"
-#include <qdeclarative.h>
-#include <QDeclarativeView>
+#include <QSGView>
#include <QApplication>
//![0]
@@ -56,7 +55,8 @@ int main(int argc, char *argv[])
qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
//![1]
- 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/chapter4-customPropertyTypes/piechart.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
index b1f4278a95..5911f4dd49 100644
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
@@ -40,11 +40,9 @@
#include "piechart.h"
#include "pieslice.h"
-PieChart::PieChart(QDeclarativeItem *parent)
- : QDeclarativeItem(parent)
+PieChart::PieChart(QSGItem *parent)
+ : QSGItem(parent)
{
- // this doesn't need to disable QGraphicsItem::ItemHasNoContents
- // anymore since the drawing is now done in PieSlice
}
QString PieChart::name() const
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h
index d7f4473ef0..9e8139846b 100644
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h
@@ -40,12 +40,12 @@
#ifndef PIECHART_H
#define PIECHART_H
-#include <QDeclarativeItem>
+#include <QtDeclarative/QSGItem>
class PieSlice;
//![0]
-class PieChart : public QDeclarativeItem
+class PieChart : public QSGItem
{
Q_OBJECT
Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice)
@@ -56,7 +56,7 @@ class PieChart : public QDeclarativeItem
public:
//![1]
- PieChart(QDeclarativeItem *parent = 0);
+ PieChart(QSGItem *parent = 0);
QString name() const;
void setName(const QString &name);
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
index f36c8ce3f4..764ef23944 100644
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
@@ -41,11 +41,9 @@
#include <QPainter>
-PieSlice::PieSlice(QDeclarativeItem *parent)
- : QDeclarativeItem(parent)
+PieSlice::PieSlice(QSGItem *parent)
+ : QSGPaintedItem(parent)
{
- // need to disable this flag to draw inside a QDeclarativeItem
- setFlag(QGraphicsItem::ItemHasNoContents, false);
}
QColor PieSlice::color() const
@@ -58,11 +56,11 @@ void PieSlice::setColor(const QColor &color)
m_color = color;
}
-void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+void PieSlice::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/chapter4-customPropertyTypes/pieslice.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
index 6e5707f3e3..7163864fac 100644
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
@@ -40,22 +40,22 @@
#ifndef PIESLICE_H
#define PIESLICE_H
-#include <QDeclarativeItem>
+#include <QtDeclarative/QSGPaintedItem>
#include <QColor>
//![0]
-class PieSlice : public QDeclarativeItem
+class PieSlice : public QSGPaintedItem
{
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor)
public:
- PieSlice(QDeclarativeItem *parent = 0);
+ PieSlice(QSGItem *parent = 0);
QColor color() const;
void setColor(const QColor &color);
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ void paint(QPainter *painter);
private:
QColor m_color;