Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QQuickView Class

The QQuickView class provides a window for displaying a Qt Quick user interface. More...

 #include <QQuickView>

Inherits: QQuickCanvas.

This class was introduced in QtQuick 2.0.

Public Types

enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView }
enum Status { Null, Ready, Loading, Error }
enum SurfaceClass { Window }
enum SurfaceType { RasterSurface, OpenGLSurface }

Properties

Public Functions

QQuickView(QWindow * parent = 0, Qt::WindowFlags f = Qt::Window)
QQuickView(QQmlEngine * engine, QWindow * parent, Qt::WindowFlags f = Qt::Window)
QQuickView(const QUrl & source, QWindow * parent = 0, Qt::WindowFlags f = Qt::Window)
virtual ~QQuickView()
virtual ~QSurface()
QQmlEngine * engine() const
QList<QQmlError> errors() const
virtual QSurfaceFormat format() const = 0
QSize initialSize() const
ResizeMode resizeMode() const
QQmlContext * rootContext() const
QQuickItem * rootObject() const
void setResizeMode(ResizeMode)
virtual QSize size() const = 0
QUrl source() const
Status status() const
SurfaceClass surfaceClass() const
virtual QPlatformSurface * surfaceHandle() const = 0
virtual SurfaceType surfaceType() const = 0
  • 24 public functions inherited from QQuickCanvas
  • 69 public functions inherited from QWindow
  • 31 public functions inherited from QObject

Public Slots

void setSource(const QUrl & url)

Signals

void statusChanged(QQuickView::Status status)

Protected Functions

QSurface(SurfaceClass type)

Reimplemented Protected Functions

virtual void keyPressEvent(QKeyEvent * e)
virtual void keyReleaseEvent(QKeyEvent * e)
virtual void mouseMoveEvent(QMouseEvent * e)
virtual void mousePressEvent(QMouseEvent * e)
virtual void mouseReleaseEvent(QMouseEvent * e)
  • 14 protected functions inherited from QQuickCanvas
  • 17 protected functions inherited from QWindow
  • 9 protected functions inherited from QObject

Additional Inherited Members

  • 11 static public members inherited from QObject

Detailed Description

The QQuickView class provides a window for displaying a Qt Quick user interface.

This is a convenience subclass of QQuickCanvas which will automatically load and display a QML scene when given the URL of the main source file. Alternatively, you can instantiate your own objects using QQmlComponent and place them in a manually setup QQuickCanvas.

Typical usage:

 QQuickView *view = new QQuickView;
 view->setSource(QUrl::fromLocalFile("myqmlfile.qml"));
 view->show();

To receive errors related to loading and executing QML with QQuickView, you can connect to the statusChanged() signal and monitor for QQuickView::Error. The errors are available via QQuickView::errors().

See also Using QML Bindings in C++ Applications.

Member Type Documentation

enum QQuickView::ResizeMode

This enum specifies how to resize the view.

ConstantValueDescription
QQuickView::SizeViewToRootObject0The view resizes with the root item in the QML.
QQuickView::SizeRootObjectToView1The view will automatically resize the root item to the size of the view.

enum QQuickView::Status

Specifies the loading status of the QQuickView.

ConstantValueDescription
QQuickView::Null0This QQuickView has no source set.
QQuickView::Ready1This QQuickView has loaded and created the QML component.
QQuickView::Loading2This QQuickView is loading network data.
QQuickView::Error3One or more errors has occurred. Call errors() to retrieve a list of errors.

Property Documentation

resizeMode : ResizeMode

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)

source : QUrl

This property holds the URL of the source of the QML component.

Changing this property causes the QML component to be reloaded.

Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.

Access functions:

QUrl source() const
void setSource(const QUrl & url)

status : const Status

The component's current status.

Access functions:

Status status() const

Notifier signal:

void statusChanged(QQuickView::Status status)

Member Function Documentation

QQuickView::QQuickView(QWindow * parent = 0, Qt::WindowFlags f = Qt::Window)

Constructs a QQuickView with the given parent and window flags f. The default value of parent is 0, default window flags f is Qt::Window.

See also Qt::WindowFlags.

QQuickView::QQuickView(QQmlEngine * engine, QWindow * parent, Qt::WindowFlags f = Qt::Window)

Constructs a QQuickView with the given QML engine, parent and a window flags f. The default value of parent is 0, default window flags f is Qt::Window.

Note: In this case, the QQuickView does not own the given engine object; it is the caller's responsibility to destroy the engine. If the engine is deleted before the view status() will return QQuickView::Error.

See also Status, status(), errors(), and Qt::WindowFlags.

QQuickView::QQuickView(const QUrl & source, QWindow * parent = 0, Qt::WindowFlags f = Qt::Window)

QQuickView::~QQuickView() [virtual]

QQmlEngine * QQuickView::engine() const

Returns a pointer to the QQmlEngine used for instantiating QML Components.

QList<QQmlError> QQuickView::errors() const

Return the list of errors that occurred during the last compile or create operation. When the status is not Error, an empty list is returned.

QSize QQuickView::initialSize() const

Returns the initial size of the root object

void QQuickView::keyPressEvent(QKeyEvent * e) [virtual protected]

Reimplemented from QWindow::keyPressEvent().

void QQuickView::keyReleaseEvent(QKeyEvent * e) [virtual protected]

Reimplemented from QWindow::keyReleaseEvent().

void QQuickView::mouseMoveEvent(QMouseEvent * e) [virtual protected]

Reimplemented from QWindow::mouseMoveEvent().

void QQuickView::mousePressEvent(QMouseEvent * e) [virtual protected]

Reimplemented from QWindow::mousePressEvent().

void QQuickView::mouseReleaseEvent(QMouseEvent * e) [virtual protected]

Reimplemented from QWindow::mouseReleaseEvent().

QQmlContext * QQuickView::rootContext() const

This function returns the root of the context hierarchy. Each QML component is instantiated in a QQmlContext. QQmlContext's are essential for passing data to QML components. In QML, contexts are arranged hierarchically and this hierarchy is managed by the QQmlEngine.

QQuickItem * QQuickView::rootObject() const

Returns the view's root item.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web