![]() |
Home · All Classes · All Functions · Overviews |
The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface. More...
#include <QDeclarativeView>
Inherits QGraphicsView.
This class was introduced in Qt 4.7.
enum | ResizeMode { SizeViewToRootObject, SizeRootObjectToView } |
enum | Status { Null, Ready, Loading, Error } |
QDeclarativeView ( QWidget * parent = 0 ) | |
QDeclarativeView ( const QUrl & source, QWidget * parent = 0 ) | |
virtual | ~QDeclarativeView () |
QDeclarativeEngine * | engine () |
QList<QDeclarativeError> | errors () const |
ResizeMode | resizeMode () const |
QDeclarativeContext * | rootContext () |
QGraphicsObject * | rootObject () const |
void | setResizeMode ( ResizeMode ) |
void | setSource ( const QUrl & url ) |
QUrl | source () const |
Status | status () const |
void | sceneResized ( QSize size ) |
void | statusChanged ( QDeclarativeView::Status status ) |
The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface.
Any QGraphicsObject or QDeclarativeItem created via QML can be placed on a standard QGraphicsScene and viewed with a standard QGraphicsView.
QDeclarativeView is a QGraphicsView subclass provided as a convenience for displaying QML files, and connecting between QML and C++ Qt objects.
QDeclarativeView performs the following functions:
Typical usage:
... QDeclarativeView *view = new QDeclarativeView(this); vbox->addWidget(view); QUrl url(fileName); view->setSource(url); view->show();
To receive errors related to loading and executing QML with QDeclarativeView, you can connect to the statusChanged() signal and monitor for QDeclarativeView::Error. The errors are available via QDeclarativeView::errors().
Specifies the loading status of the QDeclarativeView.
Constant | Value | Description |
---|---|---|
QDeclarativeView::Null | 0 | This QDeclarativeView has no source set. |
QDeclarativeView::Ready | 1 | This QDeclarativeView has loaded and created the QML component. |
QDeclarativeView::Loading | 2 | This QDeclarativeView is loading network data. |
QDeclarativeView::Error | 3 | An error has occured. Calling errorDescription() to retrieve a description. |
This property holds whether the view should resize the canvas contents.
If this property is set to SizeViewToRootObject (the default), the view resizes with the root item in the QML.
If this property is set to SizeRootObjectToView, the view will automatically resize the root item.
Regardless of this property, the sizeHint of the view is the initial size of the root item. Note though that since QML may load dynamically, that size may change.
Access functions:
ResizeMode | resizeMode () const |
void | setResizeMode ( ResizeMode ) |
See also initialSize().
Access functions:
QUrl | source () const |
void | setSource ( const QUrl & url ) |
The component's current status.
Access functions:
Status | status () const |
Notifier signal:
void | statusChanged ( QDeclarativeView::Status status ) |
Constructs a QDeclarativeView with the given parent.
Constructs a QDeclarativeView with the given QML source and parent.
The destructor clears the view's items and deletes the internal representation.
Returns a pointer to the QDeclarativeEngine used for instantiating QML Components.
Return the list of errors that occured during the last compile or create operation. An empty list is returned if isError() is not set.
This function returns the root of the context hierarchy. Each QML component is instantiated in a QDeclarativeContext. QDeclarativeContext's are essential for passing data to QML components. In QML, contexts are arranged hierarchically and this hierarchy is managed by the QDeclarativeEngine.
Returns the view's root item.
This signal is emitted when the view is resized to size.
This signal is emitted when the component's current status changes.
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt 4.7.0 |