summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-05-12 01:33:56 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-05-12 01:35:06 (GMT)
commit855368e447a1db8f72c1ad135b9edfb9c373a01d (patch)
tree067fb4ed5b644f71ba1d1db00d12057dcfacfef3
parenta19df56265e59bb26f927638aa5c75ccd666c388 (diff)
downloadQt-855368e447a1db8f72c1ad135b9edfb9c373a01d.zip
Qt-855368e447a1db8f72c1ad135b9edfb9c373a01d.tar.gz
Qt-855368e447a1db8f72c1ad135b9edfb9c373a01d.tar.bz2
Qt.widgets was removed, point to graphics layouts example
-rw-r--r--doc/src/declarative/integrating.qdoc50
-rw-r--r--doc/src/snippets/declarative/graphicswidgets/bluecircle.h55
-rw-r--r--doc/src/snippets/declarative/graphicswidgets/graphicswidgets.pro13
-rw-r--r--doc/src/snippets/declarative/graphicswidgets/main.qml32
-rw-r--r--doc/src/snippets/declarative/graphicswidgets/qmldir1
-rw-r--r--doc/src/snippets/declarative/graphicswidgets/redsquare.h54
-rw-r--r--doc/src/snippets/declarative/graphicswidgets/shapesplugin.cpp61
7 files changed, 5 insertions, 261 deletions
diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc
index 1c07f8e..972976f 100644
--- a/doc/src/declarative/integrating.qdoc
+++ b/doc/src/declarative/integrating.qdoc
@@ -110,51 +110,11 @@ of QML UIs:
\section2 Loading QGraphicsWidget objects in QML
An alternative approach is to expose your existing QGraphicsWidget objects to
-QML and construct your scene in QML instead. To do this, you need to register
-any custom C++ types and create a plugin that registers the custom types
-so that they can be used from your QML file.
+QML and construct your scene in QML instead. See the \l {declarative/layouts/graphicsLayouts}{graphics layouts example}
+which shows how to expose Qt's graphics layout classes to QML in order
+to use QGraphicsWidget with classes like QGraphicsLinearLayout and QGraphicsGridLayout.
-Here is an example. Suppose you have two classes, \c RedSquare and \c BlueCircle,
-that both inherit from QGraphicsWidget:
-
-\c [graphicswidgets/redsquare.h]
-\snippet doc/src/snippets/declarative/graphicswidgets/redsquare.h 0
-
-\c [graphicswidgets/bluecircle.h]
-\snippet doc/src/snippets/declarative/graphicswidgets/bluecircle.h 0
-
-Then, create a plugin by subclassing QDeclarativeExtensionPlugin, and register the
-types by calling qmlRegisterType(). Also export the plugin with Q_EXPORT_PLUGIN2.
-
-\c [graphicswidgets/shapesplugin.cpp]
-\snippet doc/src/snippets/declarative/graphicswidgets/shapesplugin.cpp 0
-
-Now write a project file that creates the plugin:
-
-\c [graphicswidgets/graphicswidgets.pro]
-\quotefile doc/src/snippets/declarative/graphicswidgets/graphicswidgets.pro
-
-And add a \c qmldir file that includes the \c graphicswidgets plugin from the \c lib
-subdirectory (as defined in the project file):
-
-\c [graphicswidgets/qmldir]
-\quotefile doc/src/snippets/declarative/graphicswidgets/qmldir
-
-Now, we can write a QML file that uses the \c RedSquare and \c BlueCircle widgets.
-(As an example, we can also create \c QGraphicsWidget items if we import the \c Qt.widgets
-module.)
-
-\c [main.qml]
-\quotefile doc/src/snippets/declarative/graphicswidgets/main.qml
-
-Here is a screenshot of the result:
-
-\image declarative-integrating-graphicswidgets.png
-
-
-Note this approach of creating your graphics objects from QML does not work
-with QGraphicsItems that are not QGraphicsObject-based, since they are not QObjects.
-
-See \l{Extending QML in C++} for further information on using C++ types.
+To expose your existing QGraphicsWidget classes to QML, use \l {qmlRegisterType()}.
+See \l{Extending QML in C++} for further information on using C++ types in QML.
*/
diff --git a/doc/src/snippets/declarative/graphicswidgets/bluecircle.h b/doc/src/snippets/declarative/graphicswidgets/bluecircle.h
deleted file mode 100644
index 73d66b7..0000000
--- a/doc/src/snippets/declarative/graphicswidgets/bluecircle.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-//![0]
-#include <QGraphicsWidget>
-#include <QPainter>
-
-class BlueCircle : public QGraphicsWidget
-{
- Q_OBJECT
-public:
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
- {
- painter->setPen(QColor(Qt::blue));
- painter->drawEllipse(0, 0, size().width(), size().height());
- }
-};
-//![0]
diff --git a/doc/src/snippets/declarative/graphicswidgets/graphicswidgets.pro b/doc/src/snippets/declarative/graphicswidgets/graphicswidgets.pro
deleted file mode 100644
index 21c8a37..0000000
--- a/doc/src/snippets/declarative/graphicswidgets/graphicswidgets.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = lib
-CONFIG += qt plugin
-QT += declarative
-
-HEADERS += redsquare.h \
- bluecircle.h
-
-SOURCES += shapesplugin.cpp
-
-DESTDIR = lib
-OBJECTS_DIR = tmp
-MOC_DIR = tmp
-
diff --git a/doc/src/snippets/declarative/graphicswidgets/main.qml b/doc/src/snippets/declarative/graphicswidgets/main.qml
deleted file mode 100644
index ffcf79d..0000000
--- a/doc/src/snippets/declarative/graphicswidgets/main.qml
+++ /dev/null
@@ -1,32 +0,0 @@
-import Qt 4.7
-import Qt.widgets 4.7
-
-Rectangle {
- width: 200
- height: 200
-
- RedSquare {
- id: square
- width: 80
- height: 80
- }
-
- BlueCircle {
- anchors.left: square.right
- width: 80
- height: 80
- }
-
- QGraphicsWidget {
- anchors.top: square.bottom
- size.width: 80
- size.height: 80
- layout: QGraphicsLinearLayout {
- LayoutItem {
- preferredSize: "100x100"
- Rectangle { color: "yellow"; anchors.fill: parent }
- }
- }
- }
-}
-
diff --git a/doc/src/snippets/declarative/graphicswidgets/qmldir b/doc/src/snippets/declarative/graphicswidgets/qmldir
deleted file mode 100644
index f94dad2..0000000
--- a/doc/src/snippets/declarative/graphicswidgets/qmldir
+++ /dev/null
@@ -1 +0,0 @@
-plugin graphicswidgets lib
diff --git a/doc/src/snippets/declarative/graphicswidgets/redsquare.h b/doc/src/snippets/declarative/graphicswidgets/redsquare.h
deleted file mode 100644
index 3050662..0000000
--- a/doc/src/snippets/declarative/graphicswidgets/redsquare.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-//![0]
-#include <QGraphicsWidget>
-#include <QPainter>
-
-class RedSquare : public QGraphicsWidget
-{
- Q_OBJECT
-public:
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
- {
- painter->fillRect(0, 0, size().width(), size().height(), QColor(Qt::red));
- }
-};
-//![0]
diff --git a/doc/src/snippets/declarative/graphicswidgets/shapesplugin.cpp b/doc/src/snippets/declarative/graphicswidgets/shapesplugin.cpp
deleted file mode 100644
index 4c18ef3..0000000
--- a/doc/src/snippets/declarative/graphicswidgets/shapesplugin.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-//![0]
-#include "redsquare.h"
-#include "bluecircle.h"
-
-#include <QtDeclarative/QDeclarativeExtensionPlugin>
-#include <QtDeclarative/qdeclarative.h>
-
-class ShapesPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
-public:
- void registerTypes(const char *uri) {
- qmlRegisterType<RedSquare>(uri, 1, 0, "RedSquare");
- qmlRegisterType<BlueCircle>(uri, 1, 0, "BlueCircle");
- }
-};
-
-#include "shapesplugin.moc"
-
-Q_EXPORT_PLUGIN2(shapesplugin, ShapesPlugin);
-//![0]