Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-updates > by-pkgid > 6e2327ca1c896c6d674ae53117299f21 > files > 73

qtdeclarative5-doc-5.12.6-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickpackage.cpp -->
  <title>Package QML Type | Qt QML 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtqml-index.html">Qt QML</a></td><td ><a href="qtqml-qmlmodule.html">QML Types</a></td><td >Package QML Type</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtqml-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#attached-properties">Attached Properties</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Package QML Type</h1>
<span class="subtitle"></span>
<!-- $$$Package-brief -->
<p>Specifies a collection of named items. <a href="#details">More...</a></p>
<!-- @@@Package -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import  .</td></tr></table></div><ul>
<li><a href="qml-package-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="attached-properties"></a>
<h2 id="attached-properties">Attached Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-package.html#name-attached-prop">name</a></b></b> : string</li>
</ul>
<!-- $$$Package-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
<p>The Package type is used in conjunction with <a href="qml-qtqml-models-delegatemodel.html">DelegateModel</a> to enable delegates with a shared context to be provided to multiple views.</p>
<p>Any item within a Package may be assigned a name via the <a href="qml-package.html#name-attached-prop">Package.name</a> attached property.</p>
<p>The example below creates a Package containing two named items; <i>list</i> and <i>grid</i>. The third item in the package (the Rectangle) is parented to whichever delegate it should appear in. This allows an item to move between views.</p>
<pre class="qml">

  Package {
      Text { id: listDelegate; width: parent.width; height: 25; text: 'Empty'; Package.name: 'list' }
      Text { id: gridDelegate; width: parent.width / 2; height: 50; text: 'Empty'; Package.name: 'grid' }

      Rectangle {
          id: wrapper
          width: parent.width; height: 25
          color: 'lightsteelblue'

          Text { text: display; anchors.centerIn: parent }
          state: root.upTo > index ? 'inGrid' : 'inList'
          states: [
              State {
                  name: 'inList'
                  ParentChange { target: wrapper; parent: listDelegate }
              },
              State {
                  name: 'inGrid'
                  ParentChange {
                      target: wrapper; parent: gridDelegate
                      x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height
                  }
              }
          ]

          transitions: [
              Transition {
                  ParentAnimation {
                      NumberAnimation { properties: 'x,y,width,height'; duration: 300 }
                  }
              }
          ]
      }
  }

</pre>
<p>These named items are used as the delegates by the two views who reference the special <a href="qml-qtqml-models-delegatemodel.html#parts-prop">DelegateModel::parts</a> property to select a model which provides the chosen delegate.</p>
<pre class="qml">

  DelegateModel {
      id: visualModel
      delegate: Delegate {}
      model: myModel
  }

  ListView {
      id: lv
      height: parent.height/2
      width: parent.width

      model: visualModel.parts.list
  }
  GridView {
      y: parent.height/2
      height: parent.height/2
      width: parent.width
      cellWidth: width / 2
      cellHeight: 50
      model: visualModel.parts.grid
  }

</pre>
<p><b>See also </b>Qt Quick Examples - Views, Qt Quick Demo - Photo Viewer, and <a href="qtqml-index.html">Qt QML</a>.</p>
<!-- @@@Package -->
<h2>Attached Property Documentation</h2>
<!-- $$$name -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="name-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="name-attached-prop"></a><span class="name">Package.name</span> : <span class="type"><a href="qml-string.html">string</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This attached property holds the name of an item within a Package.</p>
</div></div><!-- @@@name -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>