QDeclarativeView

概要

函数

虚函数

信号

详细描述

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

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

PySide.QtDeclarative.QDeclarativeView provides:

Typical usage:

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

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

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

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

另请参阅

Integrating QML Code with Existing Qt UI Code Using QML Bindings in C++ Applications

class PySide.QtDeclarative. QDeclarativeView ( [ parent=None ] )
class PySide.QtDeclarative. QDeclarativeView ( source [ , parent=None ] )
参数:

构造 PySide.QtDeclarative.QDeclarativeView with the given parent .

构造 PySide.QtDeclarative.QDeclarativeView with the given QML source and parent .

PySide.QtDeclarative.QDeclarativeView. ResizeMode

This enum specifies how to resize the view.

常量 描述
QDeclarativeView.SizeViewToRootObject The view resizes with the root item in the QML.
QDeclarativeView.SizeRootObjectToView The view will automatically resize the root item to the size of the view.
PySide.QtDeclarative.QDeclarativeView. 状态

Specifies the loading status of the PySide.QtDeclarative.QDeclarativeView .

常量 描述
QDeclarativeView.Null This PySide.QtDeclarative.QDeclarativeView has no source set.
QDeclarativeView.Ready This PySide.QtDeclarative.QDeclarativeView has loaded and created the QML component.
QDeclarativeView.Loading This PySide.QtDeclarative.QDeclarativeView is loading network data.
QDeclarativeView.Error One or more errors has occurred. Call PySide.QtDeclarative.QDeclarativeView.errors() to retrieve a list of errors.
PySide.QtDeclarative.QDeclarativeView. continueExecute ( )
PySide.QtDeclarative.QDeclarativeView. engine ( )
返回类型: PySide.QtDeclarative.QDeclarativeEngine

返回指针指向 PySide.QtDeclarative.QDeclarativeEngine used for instantiating QML Components.

PySide.QtDeclarative.QDeclarativeView. errors ( )
返回类型:

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.

PySide.QtDeclarative.QDeclarativeView. initialSize ( )
返回类型: PySide.QtCore.QSize

Returns the initial size of the root object

PySide.QtDeclarative.QDeclarativeView. resizeMode ( )
返回类型: PySide.QtDeclarative.QDeclarativeView.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.

PySide.QtDeclarative.QDeclarativeView. rootContext ( )
返回类型: PySide.QtDeclarative.QDeclarativeContext

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

PySide.QtDeclarative.QDeclarativeView. rootObject ( )
返回类型: PySide.QtGui.QGraphicsObject

Returns the view's root item .

PySide.QtDeclarative.QDeclarativeView. sceneResized ( size )
参数: size PySide.QtCore.QSize
PySide.QtDeclarative.QDeclarativeView. setResizeMode ( arg__1 )
参数: arg__1 PySide.QtDeclarative.QDeclarativeView.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.

PySide.QtDeclarative.QDeclarativeView. setRootObject ( obj )
参数: obj PySide.QtCore.QObject
PySide.QtDeclarative.QDeclarativeView. setSource ( arg__1 )
参数: arg__1 PySide.QtCore.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.

另请参阅

Loading Resources in QML

PySide.QtDeclarative.QDeclarativeView. source ( )
返回类型: PySide.QtCore.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.

另请参阅

Loading Resources in QML

PySide.QtDeclarative.QDeclarativeView. status ( )
返回类型: PySide.QtDeclarative.QDeclarativeView.Status

The component's current status .

PySide.QtDeclarative.QDeclarativeView. statusChanged ( arg__1 )
参数: arg__1 PySide.QtDeclarative.QDeclarativeView.Status