QQuickViewclass provides a window for displaying a Qt Quick user interface. 更多 …
def
engine
()
def
errors
()
def
initialSize
()
def
resizeMode
()
def
rootContext
()
def
rootObject
()
def
setResizeMode
(arg__1)
def
sizeHint
()
def
source
()
def
status
()
def
setContent
(url, component, item)
def
setInitialProperties
(initialProperties)
def
setSource
(arg__1)
def
statusChanged
(arg__1)
这是方便子类化的
QQuickWindow将自动加载并显示 QML 场景当有给出主源文件的 URL 时。另外,可以实例化自己的对象使用QQmlComponent并放置它们以手动设置QQuickWindow.典型用法:
if __name__ == '__main__': app = QGuiApplication(sys.argv) view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) qmlFile = os.path.join(os.path.dirname(__file__), 'view.qml') view.setSource(QUrl.fromLocalFile(os.path.abspath(qmlFile))) if view.status() == QQuickView.Error: sys.exit(-1) view.show() app.exec_() # Deleting the view before it goes out of scope is required to make # sure all child QML instances are destroyed in the correct order. del viewTo receive errors related to loading and executing QML with
QQuickView, you can connect to thestatusChanged()signal and monitor forError. The errors are available viaerrors().
QQuickViewalso manages sizing of the view and root object. By default, theresizeModeisSizeViewToRootObject, which will load the component and resize it to the size of the view. Alternatively theresizeModemay be set toSizeRootObjectToViewwhich will resize the view to the size of the root object.另请参阅
将 C++ 类型属性暴露给 QML
QQuickWidget
QQuickView
(
engine
,
parent
)
¶
QQuickView([parent=None])
QQuickView(source, renderControl)
QQuickView(source[, parent=None])
- param parent
QWindow- param source
QUrl- param renderControl
- param engine
QQmlEngine
构造
QQuickView
with the given QML
engine
and
parent
.
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
Error
.
构造
QQuickView
采用给定
parent
. The default value of
parent
为 0。
PySide2.QtQuick.QQuickView.
ResizeMode
¶
This enum specifies how to resize the view.
|
常量 |
描述 |
|---|---|
|
QQuickView.SizeViewToRootObject |
The view resizes with the root item in the QML. |
|
QQuickView.SizeRootObjectToView |
The view will automatically resize the root item to the size of the view. |
PySide2.QtQuick.QQuickView.
Status
¶
Specifies the loading status of the
QQuickView
.
|
常量 |
描述 |
|---|---|
|
QQuickView.Null |
This
|
|
QQuickView.Ready |
This
|
|
QQuickView.Loading |
This
|
|
QQuickView.Error |
One or more errors has occurred. Call
|
PySide2.QtQuick.QQuickView.
engine
(
)
¶
QQmlEngine
返回指针指向
QQmlEngine
used for instantiating QML Components.
PySide2.QtQuick.QQuickView.
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.
PySide2.QtQuick.QQuickView.
initialSize
(
)
¶
QSize
Returns the initial size of the root object.
若
resizeMode
is QQuickItem::SizeRootObjectToView the root object will be resized to the size of the view. contains the size of the root object before it was resized.
PySide2.QtQuick.QQuickView.
resizeMode
(
)
¶
另请参阅
PySide2.QtQuick.QQuickView.
rootContext
(
)
¶
QQmlContext
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
.
PySide2.QtQuick.QQuickView.
setContent
(
url
,
component
,
item
)
¶
url
–
QUrl
component
–
QQmlComponent
item
–
QObject
Set the source
url
,
component
and content
item
(root of the QML object hierarchy) directly.
PySide2.QtQuick.QQuickView.
setInitialProperties
(
initialProperties
)
¶
initialProperties –
Sets the initial properties
initialProperties
with which the QML component gets initialized after calling
setSource()
.
注意
You can only use this function to initialize top-level properties.
另请参阅
createWithInitialProperties()
PySide2.QtQuick.QQuickView.
setResizeMode
(
arg__1
)
¶
arg__1
–
ResizeMode
另请参阅
PySide2.QtQuick.QQuickView.
setSource
(
arg__1
)
¶
arg__1
–
QUrl
Sets the source to the
url
, loads the QML component and instantiates it.
Ensure that the URL provided is full and correct, in particular, use
fromLocalFile()
when loading a file from the local filesystem.
Calling this method multiple times with the same url will result in the QML component being reinstantiated.
另请参阅
PySide2.QtQuick.QQuickView.
sizeHint
(
)
¶
QSize
Preferred size follows the root object geometry.
PySide2.QtQuick.QQuickView.
source
(
)
¶
QUrl
Returns the source URL, if set.
另请参阅