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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QDeclarativeView Class Reference

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.

Public Types

enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView }
enum Status { Null, Ready, Loading, Error }

Properties

Public Functions

QDeclarativeView ( QWidget * parent = 0 )
QDeclarativeView ( const QUrl & source, QWidget * parent = 0 )
virtual ~QDeclarativeView ()
QDeclarativeEngine * engine () const
QList<QDeclarativeError> errors () const
QSize initialSize () const
ResizeMode resizeMode () const
QDeclarativeContext * rootContext () const
QGraphicsObject * rootObject () const
void setResizeMode ( ResizeMode )
void setSource ( const QUrl & url )
QUrl source () const
Status status () const

Signals

void sceneResized ( QSize size )
void statusChanged ( QDeclarativeView::Status status )

Additional Inherited Members

Detailed Description

The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface.

QDeclarativeItem objects can be placed on a standard QGraphicsScene and displayed with QGraphicsView. QDeclarativeView is a QGraphicsView subclass provided as a convenience for displaying QML files, and connecting between QML and C++ Qt objects.

QDeclarativeView provides:

Typical usage:

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

Since QDeclarativeView is a QWidget-based class, it can be used to display QML interfaces within QWidget-based GUI applications that do not use the Graphics View framework.

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().

If you're using your own QGraphicsScene-based scene with QDeclarativeView, remember to enable scene's sticky focus mode and to set itemIndexMethod to QGraphicsScene::NoIndex.

See also Integrating QML Code with Existing Qt UI Code and Using QML Bindings in C++ Applications.

Member Type Documentation

enum QDeclarativeView::ResizeMode

This enum specifies how to resize the view.

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

enum QDeclarativeView::Status

Specifies the loading status of the QDeclarativeView.

ConstantValueDescription
QDeclarativeView::Null0This QDeclarativeView has no source set.
QDeclarativeView::Ready1This QDeclarativeView has loaded and created the QML component.
QDeclarativeView::Loading2This QDeclarativeView is loading network data.
QDeclarativeView::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 ( QDeclarativeView::Status status )

Member Function Documentation

QDeclarativeView::QDeclarativeView ( QWidget * parent = 0 )

Constructs a QDeclarativeView with the given parent.

QDeclarativeView::QDeclarativeView ( const QUrl & source, QWidget * parent = 0 )

Constructs a QDeclarativeView with the given QML source and parent.

QDeclarativeView::~QDeclarativeView () [virtual]

Destroys the view.

QDeclarativeEngine * QDeclarativeView::engine () const

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

QList<QDeclarativeError> QDeclarativeView::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 QDeclarativeView::initialSize () const

Returns the initial size of the root object

QDeclarativeContext * QDeclarativeView::rootContext () const

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.

QGraphicsObject * QDeclarativeView::rootObject () const

Returns the view's root item.

void QDeclarativeView::sceneResized ( QSize size ) [signal]

This signal is emitted when the view is resized to size.

void QDeclarativeView::statusChanged ( QDeclarativeView::Status status ) [signal]

This signal is emitted when the component's current status changes.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 69
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique PyQt/PySide a besoin de vous ! 0
Page suivante

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

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 4.7-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