** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
import "ImageProviderCore" // import the plugin that registers the color image provider
//![0]
Column {
- Image { source: "source://colors/yellow" }
- Image { source: "source://colors/red" }
+ Image { source: "image://colors/yellow" }
+ Image { source: "image://colors/red" }
}
//![0]
#include <qdeclarativeextensionplugin.h>
#include <qdeclarativeengine.h>
-#include <qdeclarative.h>
-#include <qdeclarativeitem.h>
#include <qdeclarativeimageprovider.h>
-#include <qdeclarativeview.h>
#include <QImage>
#include <QPainter>
TEMPLATE = lib
CONFIG += qt plugin
-QT += declarative qtquick1
+QT += declarative
DESTDIR = ImageProviderCore
TARGET = qmlimageproviderplugin
#include <QDeclarativeEngine>
#include <QDeclarativeNetworkAccessManagerFactory>
-#include <QDeclarativeView>
+#include <QSGView>
/*
}
}
- QDeclarativeView view;
+ QSGView view;
view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory);
view.setSource(source);
TARGET = networkaccessmanagerfactory
DEPENDPATH += .
INCLUDEPATH += .
-QT += declarative network qtquick1
+QT += declarative network
# Input
SOURCES += main.cpp
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
Image {
width: 100
To run:
make install
- qmlviewer -I . plugins.qml
+ QML_IMPORT_PATH=$PWD qmlscene plugins.qml
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
Rectangle {
id: clock
hours: time.hour
minutes: time.minute
+
}
//![0]
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
import People 1.0
// ![0]
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
import QtQuick 2.0
Item {
****************************************************************************/
//![0]
import Charts 1.0
-import QtQuick 1.0
+import QtQuick 2.0
Item {
width: 300; height: 200
-QT += declarative qtquick1
+QT += declarative
HEADERS += piechart.h
SOURCES += piechart.cpp \
****************************************************************************/
//![0]
#include "piechart.h"
-#include <qdeclarative.h>
-#include <QDeclarativeView>
+#include <QSGView>
#include <QApplication>
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();
#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]
}
//![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]
#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);
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;
****************************************************************************/
//![0]
import Charts 1.0
-import QtQuick 1.0
+import QtQuick 2.0
Item {
width: 300; height: 200
-QT += declarative qtquick1
+QT += declarative
HEADERS += piechart.h
SOURCES += piechart.cpp \
****************************************************************************/
//![0]
#include "piechart.h"
-#include <qdeclarative.h>
-#include <QDeclarativeView>
+#include <QSGView>
#include <QApplication>
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();
****************************************************************************/
#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
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);
}
#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
public:
//![1]
- PieChart(QDeclarativeItem *parent = 0);
+ PieChart(QSGItem *parent = 0);
QString name() const;
void setName(const QString &name);
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();
****************************************************************************/
//![0]
import Charts 1.0
-import QtQuick 1.0
+import QtQuick 2.0
Item {
width: 300; height: 200
-QT += declarative qtquick1
+QT += declarative
HEADERS += piechart.h
SOURCES += piechart.cpp \
****************************************************************************/
//![0]
#include "piechart.h"
-#include <qdeclarative.h>
-#include <QDeclarativeView>
+#include <QSGView>
#include <QApplication>
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();
****************************************************************************/
#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
}
//![0]
-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);
}
#ifndef PIECHART_H
#define PIECHART_H
-#include <QDeclarativeItem>
#include <QColor>
+#include <QtDeclarative/QSGPaintedItem>
//![0]
-class PieChart : public QDeclarativeItem
+class PieChart : public QSGPaintedItem
{
//![0]
Q_OBJECT
public:
//![1]
- PieChart(QDeclarativeItem *parent = 0);
+ PieChart(QSGItem *parent = 0);
QString name() const;
void setName(const QString &name);
QColor color() const;
void setColor(const QColor &color);
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ void paint(QPainter *painter);
Q_INVOKABLE void clearChart();
****************************************************************************/
//![0]
import Charts 1.0
-import QtQuick 1.0
+import QtQuick 2.0
Item {
width: 300; height: 200
-QT += declarative qtquick1
+QT += declarative
HEADERS += piechart.h \
pieslice.h
#include "piechart.h"
#include "pieslice.h"
-#include <qdeclarative.h>
-#include <QDeclarativeView>
+#include <QSGView>
#include <QApplication>
//![0]
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();
#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
#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)
public:
//![1]
- PieChart(QDeclarativeItem *parent = 0);
+ PieChart(QSGItem *parent = 0);
QString name() const;
void setName(const QString &name);
#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
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);
}
#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;
****************************************************************************/
//![0]
import Charts 1.0
-import QtQuick 1.0
+import QtQuick 2.0
Item {
width: 300; height: 200
-QT += declarative qtquick1
+QT += declarative
HEADERS += piechart.h \
pieslice.h
#include "piechart.h"
#include "pieslice.h"
-#include <qdeclarative.h>
-#include <QDeclarativeView>
+#include <QSGView>
#include <QApplication>
int main(int argc, char *argv[])
qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
- QDeclarativeView view;
+ QSGView view;
+ view.setResizeMode(QSGView::SizeRootObjectToView);
view.setSource(QUrl::fromLocalFile("app.qml"));
view.show();
return app.exec();
#include "piechart.h"
#include "pieslice.h"
-PieChart::PieChart(QDeclarativeItem *parent)
- : QDeclarativeItem(parent)
+PieChart::PieChart(QSGItem *parent)
+ : QSGItem(parent)
{
}
#ifndef PIECHART_H
#define PIECHART_H
-#include <QDeclarativeItem>
+#include <QSGItem>
class PieSlice;
//![0]
-class PieChart : public QDeclarativeItem
+class PieChart : public QSGItem
{
Q_OBJECT
Q_PROPERTY(QDeclarativeListProperty<PieSlice> slices READ slices)
//![1]
public:
//![1]
- PieChart(QDeclarativeItem *parent = 0);
+ PieChart(QSGItem *parent = 0);
QString name() const;
void setName(const QString &name);
#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
m_angleSpan = angle;
}
-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(), m_fromAngle * 16, m_angleSpan * 16);
}
#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)
//![0]
public:
- PieSlice(QDeclarativeItem *parent = 0);
+ PieSlice(QSGItem *parent = 0);
QColor color() const;
void setColor(const QColor &color);
int angleSpan() const;
void setAngleSpan(int span);
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ void paint(QPainter *painter);
private:
QColor m_color;
--- /dev/null
+plugin chartsplugin
\ No newline at end of file
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
+import "ChartsPlugin" 1.0
Item {
width: 300; height: 200
TEMPLATE = lib
CONFIG += qt plugin
-QT += declarative qtquick1
+QT += declarative
+
+DESTDIR = ChartsPlugin
+TARGET = chartsplugin
-DESTDIR = lib
OBJECTS_DIR = tmp
MOC_DIR = tmp
pieslice.cpp \
chartsplugin.cpp
-symbian {
- CONFIG += qt_example
- TARGET.EPOCALLOWDLLDATA = 1
-}
-maemo5: CONFIG += qt_example
#include "piechart.h"
#include "pieslice.h"
-PieChart::PieChart(QDeclarativeItem *parent)
- : QDeclarativeItem(parent)
+PieChart::PieChart(QSGItem *parent)
+ : QSGItem(parent)
{
}
#ifndef PIECHART_H
#define PIECHART_H
-#include <QDeclarativeItem>
+#include <QSGItem>
class PieSlice;
-class PieChart : public QDeclarativeItem
+class PieChart : public QSGItem
{
Q_OBJECT
Q_PROPERTY(QDeclarativeListProperty<PieSlice> slices READ slices)
Q_PROPERTY(QString name READ name WRITE setName)
public:
- PieChart(QDeclarativeItem *parent = 0);
+ PieChart(QSGItem *parent = 0);
QString name() const;
void setName(const QString &name);
#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
m_angleSpan = angle;
}
-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(), m_fromAngle * 16, m_angleSpan * 16);
}
#ifndef PIESLICE_H
#define PIESLICE_H
-#include <QDeclarativeItem>
+#include <QtDeclarative/QSGPaintedItem>
#include <QColor>
-class PieSlice : public QDeclarativeItem
+class PieSlice : public QSGPaintedItem
{
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor)
Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
public:
- PieSlice(QDeclarativeItem *parent = 0);
+ PieSlice(QSGItem *parent = 0);
QColor color() const;
void setColor(const QColor &color);
int angleSpan() const;
void setAngleSpan(int span);
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ void paint(QPainter *painter);
private:
QColor m_color;
+++ /dev/null
-plugin chapter6-plugins lib
load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative qtquick1
+contains(QT_CONFIG,declarative): QT += declarative
macx:CONFIG -= app_bundle
-SOURCES += tst_examples.cpp
-
-include(../../../../tools/qmlviewer/qml.pri)
-
-include(../symbianlibs.pri)
-
-symbian: {
- importFiles.files = data
- importFiles.path = .
- DEPLOYMENT += importFiles
-} else {
- DEFINES += SRCDIR=\\\"$$PWD\\\"
-}
+SOURCES += tst_examples.cpp
+DEFINES += SRCDIR=\\\"$$PWD\\\"
CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private qtquick1-private
+QT += core-private gui-private v8-private declarative-private
qpa:CONFIG+=insignificant_test # QTBUG-20990, aborts
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include <qtest.h>
#include <QLibraryInfo>
#include <QDir>
#include <QProcess>
#include <QDebug>
-#include "qmlruntime.h"
-#include <QDeclarativeView>
#include <QSGView>
#include <QDeclarativeError>
-#ifdef Q_OS_SYMBIAN
-// In Symbian OS test data is located in applications private dir
-#define SRCDIR "."
-#endif
-
class tst_examples : public QObject
{
Q_OBJECT
tst_examples();
private slots:
- void examples_data();
- void examples();
void sgexamples_data();
void sgexamples();
Examples are any .qml files under the examples/ directory that start
with a lower case letter.
*/
-void tst_examples::examples_data()
+static void silentErrorsMsgHandler(QtMsgType, const char *)
+{
+}
+
+
+void tst_examples::sgexamples_data()
{
QTest::addColumn<QString>("file");
QTest::newRow(qPrintable(file)) << file;
}
-static void silentErrorsMsgHandler(QtMsgType, const char *)
-{
-}
-
-void tst_examples::examples()
-{
- QFETCH(QString, file);
-
- QDeclarativeViewer viewer;
-
- QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler);
- QVERIFY(viewer.open(file));
- qInstallMsgHandler(old);
-
- if (viewer.view()->status() == QDeclarativeView::Error)
- qWarning() << viewer.view()->errors();
-
- QCOMPARE(viewer.view()->status(), QDeclarativeView::Ready);
- viewer.show();
-
- QTest::qWaitForWindowShown(&viewer);
-}
-
-void tst_examples::sgexamples_data()
-{
- examples_data();
-}
-
void tst_examples::sgexamples()
{
- qputenv("QMLSCENE_IMPORT_NAME", "quick1");
QFETCH(QString, file);
QSGView view;