1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDeclarativeView Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDeclarativeView Class Reference<br /><sup><sup>[<a href="qtdeclarative.html">QtDeclarative</a> module]</sup></sup></h1><p>The QDeclarativeView class provides a widget for displaying a Qt
Declarative user interface. <a href="#details">More...</a></p>
<p>Inherits <a href="qgraphicsview.html">QGraphicsView</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qdeclarativeview.html#ResizeMode-enum">ResizeMode</a></b> { SizeViewToRootObject, SizeRootObjectToView }</li><li><div class="fn" />enum <b><a href="qdeclarativeview.html#Status-enum">Status</a></b> { Null, Ready, Loading, Error }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdeclarativeview.html#QDeclarativeView">__init__</a></b> (<i>self</i>, QWidget <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qdeclarativeview.html#QDeclarativeView-2">__init__</a></b> (<i>self</i>, QUrl <i>source</i>, QWidget <i>parent</i> = None)</li><li><div class="fn" />QDeclarativeEngine <b><a href="qdeclarativeview.html#engine">engine</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QDeclarativeError <b><a href="qdeclarativeview.html#errors">errors</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdeclarativeview.html#eventFilter">eventFilter</a></b> (<i>self</i>, QObject <i>watched</i>, QEvent <i>e</i>)</li><li><div class="fn" />QSize <b><a href="qdeclarativeview.html#initialSize">initialSize</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdeclarativeview.html#paintEvent">paintEvent</a></b> (<i>self</i>, QPaintEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qdeclarativeview.html#resizeEvent">resizeEvent</a></b> (<i>self</i>, QResizeEvent)</li><li><div class="fn" />ResizeMode <b><a href="qdeclarativeview.html#resizeMode">resizeMode</a></b> (<i>self</i>)</li><li><div class="fn" />QDeclarativeContext <b><a href="qdeclarativeview.html#rootContext">rootContext</a></b> (<i>self</i>)</li><li><div class="fn" />QGraphicsObject <b><a href="qdeclarativeview.html#rootObject">rootObject</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdeclarativeview.html#setResizeMode">setResizeMode</a></b> (<i>self</i>, ResizeMode)</li><li><div class="fn" /><b><a href="qdeclarativeview.html#setSource">setSource</a></b> (<i>self</i>, QUrl)</li><li><div class="fn" />QSize <b><a href="qdeclarativeview.html#sizeHint">sizeHint</a></b> (<i>self</i>)</li><li><div class="fn" />QUrl <b><a href="qdeclarativeview.html#source">source</a></b> (<i>self</i>)</li><li><div class="fn" />Status <b><a href="qdeclarativeview.html#status">status</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdeclarativeview.html#timerEvent">timerEvent</a></b> (<i>self</i>, QTimerEvent)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qdeclarativeview.html#sceneResized">sceneResized</a></b> (QSize)</li><li><div class="fn" />void <b><a href="qdeclarativeview.html#statusChanged">statusChanged</a></b> (QDeclarativeView::Status)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDeclarativeView class provides a widget for displaying a Qt
Declarative user interface.</p>
<p><a href="qdeclarativeitem.html">QDeclarativeItem</a> objects can
be placed on a standard <a href="qgraphicsscene.html">QGraphicsScene</a> and displayed with
<a href="qgraphicsview.html">QGraphicsView</a>. QDeclarativeView is
a <a href="qgraphicsview.html">QGraphicsView</a> subclass provided
as a convenience for displaying QML files, and connecting between
QML and C++ Qt objects.</p>
<p>QDeclarativeView provides:</p>
<ul>
<li>Management of <a href="qdeclarativecomponent.html">QDeclarativeComponent</a> loading and
object creation</li>
<li>Initialization of <a href="qgraphicsview.html">QGraphicsView</a> for optimal performance with
QML using these settings:
<ul>
<li>QGraphicsView.setOptimizationFlags(<a href="qgraphicsview.html#OptimizationFlag-enum">QGraphicsView.DontSavePainterState</a>)</li>
<li>QGraphicsView.setViewportUpdateMode(<a href="qgraphicsview.html#ViewportUpdateMode-enum">QGraphicsView.BoundingRectViewportUpdate</a>)</li>
<li>QGraphicsScene.setItemIndexMethod(<a href="qgraphicsscene.html#ItemIndexMethod-enum">QGraphicsScene.NoIndex</a>)</li>
</ul>
</li>
<li>Initialization of <a href="qgraphicsview.html">QGraphicsView</a> for QML key handling using
these settings:
<ul>
<li><a href="qabstractscrollarea.html#viewport">QGraphicsView.viewport</a>()->setFocusPolicy(<a href="qt.html#FocusPolicy-enum">Qt.NoFocus</a>)</li>
<li>QGraphicsView.setFocusPolicy(<a href="qt.html#FocusPolicy-enum">Qt.StrongFocus</a>)</li>
<li>QGraphicsScene.setStickyFocus(true)</li>
</ul>
</li>
</ul>
<p>Typical usage:</p>
<pre class="cpp">
<span class="type">QDeclarativeView</span> <span class="operator">*</span>view <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QDeclarativeView</span>;
view<span class="operator">-</span><span class="operator">></span><a href="qdeclarativeview.html#source-prop">setSource</a>(<span class="type"><a href="qurl.html">QUrl</a></span><span class="operator">.</span>fromLocalFile(<span class="string">"myqmlfile.qml"</span>));
view<span class="operator">-</span><span class="operator">></span><a href="qwidget.html#show">show</a>();
</pre>
<p>Since QDeclarativeView is a <a href="qwidget.html">QWidget</a>-based class, it can be used to display
QML interfaces within <a href="qwidget.html">QWidget</a>-based GUI
applications that do not use the Graphics View framework.</p>
<p>To receive errors related to loading and executing QML with
QDeclarativeView, you can connect to the <a href="qdeclarativeview.html#statusChanged">statusChanged</a>() signal
and monitor for <a href="qdeclarativeview.html#Status-enum">QDeclarativeView.Error</a>.
The errors are available via <a href="qdeclarativeview.html#errors">QDeclarativeView.errors</a>().</p>
<p>If you're using your own <a href="qgraphicsscene.html">QGraphicsScene</a>-based scene with
QDeclarativeView, remember to enable scene's sticky focus mode and
to set itemIndexMethod to <a href="qgraphicsscene.html#ItemIndexMethod-enum">QGraphicsScene.NoIndex</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="ResizeMode-enum" />QDeclarativeView.ResizeMode</h3><p>This enum specifies how to resize the view.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign">
<tt>QDeclarativeView.SizeViewToRootObject</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">The view resizes with the root item in the
QML.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QDeclarativeView.SizeRootObjectToView</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">The view will automatically resize the root
item to the size of the view.</td>
</tr>
</table>
<h3 class="fn"><a name="Status-enum" />QDeclarativeView.Status</h3><p>Specifies the loading status of the <a href="qdeclarativeview.html">QDeclarativeView</a>.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QDeclarativeView.Null</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">This <a href="qdeclarativeview.html">QDeclarativeView</a> has no source
set.</td>
</tr>
<tr>
<td class="topAlign"><tt>QDeclarativeView.Ready</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">This <a href="qdeclarativeview.html">QDeclarativeView</a> has loaded and created
the QML component.</td>
</tr>
<tr>
<td class="topAlign"><tt>QDeclarativeView.Loading</tt></td>
<td class="topAlign"><tt>2</tt></td>
<td class="topAlign">This <a href="qdeclarativeview.html">QDeclarativeView</a> is loading network
data.</td>
</tr>
<tr>
<td class="topAlign"><tt>QDeclarativeView.Error</tt></td>
<td class="topAlign"><tt>3</tt></td>
<td class="topAlign">One or more errors has occurred. Call <a href="qdeclarativeview.html#errors">errors</a>() to retrieve a list of
errors.</td>
</tr>
</table>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDeclarativeView" />QDeclarativeView.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qdeclarativeview.html">QDeclarativeView</a> with the given
<i>parent</i>.</p>
<h3 class="fn"><a name="QDeclarativeView-2" />QDeclarativeView.__init__ (<i>self</i>, <a href="qurl.html">QUrl</a> <i>source</i>, <a href="qwidget.html">QWidget</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qdeclarativeview.html">QDeclarativeView</a> with the given QML
<i>source</i> and <i>parent</i>.</p>
<h3 class="fn"><a name="engine" /><a href="qdeclarativeengine.html">QDeclarativeEngine</a> QDeclarativeView.engine (<i>self</i>)</h3><p>Returns a pointer to the <a href="qdeclarativeengine.html">QDeclarativeEngine</a> used for
instantiating QML Components.</p>
<h3 class="fn"><a name="errors" />list-of-QDeclarativeError QDeclarativeView.errors (<i>self</i>)</h3><p>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.</p>
<h3 class="fn"><a name="eventFilter" />bool QDeclarativeView.eventFilter (<i>self</i>, <a href="qobject.html">QObject</a> <i>watched</i>, <a href="qevent.html">QEvent</a> <i>e</i>)</h3><h3 class="fn"><a name="initialSize" /><a href="qsize.html">QSize</a> QDeclarativeView.initialSize (<i>self</i>)</h3><p>Returns the initial size of the root object</p>
<h3 class="fn"><a name="paintEvent" />QDeclarativeView.paintEvent (<i>self</i>, <a href="qpaintevent.html">QPaintEvent</a> <i>event</i>)</h3><h3 class="fn"><a name="resizeEvent" />QDeclarativeView.resizeEvent (<i>self</i>, <a href="qresizeevent.html">QResizeEvent</a>)</h3><h3 class="fn"><a name="resizeMode" /><a href="qdeclarativeview.html#ResizeMode-enum">ResizeMode</a> QDeclarativeView.resizeMode (<i>self</i>)</h3><h3 class="fn"><a name="rootContext" /><a href="qdeclarativecontext.html">QDeclarativeContext</a> QDeclarativeView.rootContext (<i>self</i>)</h3><p>This function returns the root of the context hierarchy. Each
QML component is instantiated in a <a href="qdeclarativecontext.html">QDeclarativeContext</a>. <a href="qdeclarativecontext.html">QDeclarativeContext</a>'s are essential
for passing data to QML components. In QML, contexts are arranged
hierarchically and this hierarchy is managed by the <a href="qdeclarativeengine.html">QDeclarativeEngine</a>.</p>
<h3 class="fn"><a name="rootObject" /><a href="qgraphicsobject.html">QGraphicsObject</a> QDeclarativeView.rootObject (<i>self</i>)</h3><p>Returns the view's root <a href="qgraphicsobject.html">item</a>.</p>
<h3 class="fn"><a name="setResizeMode" />QDeclarativeView.setResizeMode (<i>self</i>, <a href="qdeclarativeview.html#ResizeMode-enum">ResizeMode</a>)</h3><h3 class="fn"><a name="setSource" />QDeclarativeView.setSource (<i>self</i>, <a href="qurl.html">QUrl</a>)</h3><h3 class="fn"><a name="sizeHint" /><a href="qsize.html">QSize</a> QDeclarativeView.sizeHint (<i>self</i>)</h3><h3 class="fn"><a name="source" /><a href="qurl.html">QUrl</a> QDeclarativeView.source (<i>self</i>)</h3><h3 class="fn"><a name="status" /><a href="qdeclarativeview.html#Status-enum">Status</a> QDeclarativeView.status (<i>self</i>)</h3><h3 class="fn"><a name="timerEvent" />QDeclarativeView.timerEvent (<i>self</i>, <a href="qtimerevent.html">QTimerEvent</a>)</h3><hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="sceneResized" />void sceneResized (QSize)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the view is resized to
<i>size</i>.</p>
<h3 class="fn"><a name="statusChanged" />void statusChanged (QDeclarativeView::Status)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the component's current
<i>status</i> changes.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.9.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.2</td></tr></table></div></address></body></html>
|