Sophie

Sophie

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

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" />
<!-- window.qdoc -->
  <title>Qt Quick Examples - Window and Screen | Qt Quick 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="qtquick-index.html">Qt Quick</a></td><td >Qt Quick Examples - Window and Screen</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-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="#running-the-example">Running the Example</a></li>
<li class="level1"><a href="#window-implementation">Window Implementation</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Quick Examples - Window and Screen</h1>
<span class="subtitle"></span>
<!-- $$$window-brief -->
<p>This example demonstrates the Window and Screen types in QML.</p>
<!-- @@@window -->
<!-- $$$window-description -->
<div class="descr"> <a name="details"></a>
<p class="centerAlign"><img src="images/qml-window-example.png" alt="" /></p><p><i>Window and Screen</i> shows how to:</p>
<ul>
<li>create a window in QML</li>
<li>control its visibility</li>
<li>present a splash screen during application startup</li>
<li>access the properties of the <a href="qml-qtquick-window-screen.html">Screen</a></li>
</ul>
<p>It also demonstrates how to package QML into resources and provide an icon to create a standalone QML desktop application.</p>
<a name="running-the-example"></a>
<h2 id="running-the-example">Running the Example</h2>
<p>To run the example from Qt Creator, open the <b>Welcome</b> mode and select the example from <b>Examples</b>. For more information, visit Building and Running an Example.</p>
<a name="window-implementation"></a>
<h2 id="window-implementation">Window Implementation</h2>
<p>A splash screen can be created with the Qt.SplashScreen flag, and should be ApplicationModal to prevent interaction with the main window. If the splash window is also transparent, and showing a partially transparent image, then it will look like a shaped window.</p>
<pre class="qml">

  Window {
      id: splash
      color: "transparent"
      title: "Splash Window"
      modality: Qt.ApplicationModal
      flags: Qt.SplashScreen
      property int timeoutInterval: 2000
      signal timeout

</pre>
<p>In this example a Timer will automatically dismiss the splash screen, but in a real application you might want to connect to a signal from the application logic to hide the splash when initialization is complete.</p>
<pre class="qml">

  Timer {
      interval: timeoutInterval; running: true; repeat: false
      onTriggered: {
          visible = false
          splash.timeout()
      }
  }

</pre>
<p>The main window in this example is the control window, with some buttons and checkboxes to control and provide feedback on the state of a secondary window. Each checkbox has a binding to the property whose state it is displaying, and also an onClicked handler to change the state. This is the typical pattern to create a two-way binding while avoiding binding loops.</p>
<pre class="qml">

  Shared.CheckBox {
      text: "Windowed"
      height: showButton.height
      width: col.cellWidth
      Binding on checked { value: testWindow.visibility === Window.Windowed }
      onClicked: testWindow.visibility = Window.Windowed
  }

</pre>
<p><a href="qml-qtquick-window-screen.html">Screen</a> has several properties which are generally useful to applications which need to rotate some content when the screen orientation changes, to position windows on the screen or to convert real units to logical pixel units. CurrentScreen.qml (which is displayed inline in window.qml, or can be run by itself with qmlscene) simply displays the property values, while the splash screen uses them to center the window on the screen.</p>
<pre class="qml">

      x: (Screen.width - splashImage.width) / 2
      y: (Screen.height - splashImage.height) / 2

</pre>
<p>If a <a href="qml-qtquick-window-window.html">Window</a> is nested inside an <a href="qml-qtquick-item.html">Item</a> or another Window, the inner window becomes <i>transient for</i> the outer one (see <a href="qml-qtquick-window-window.html">Window</a> for more explanation). But if you want to create multiple top-level windows as unrelated peers, you can create them inside a non-visual QtObject root item, as this example does.</p>
<p>Files:</p>
<ul>
<li><a href="qtquick-window-allscreens-qml.html">window/AllScreens.qml</a></li>
<li><a href="qtquick-window-currentscreen-qml.html">window/CurrentScreen.qml</a></li>
<li><a href="qtquick-window-splash-qml.html">window/Splash.qml</a></li>
<li><a href="qtquick-window-main-cpp.html">window/main.cpp</a></li>
<li><a href="qtquick-window-resources-icon-svg.html">window/resources/icon.svg</a></li>
<li><a href="qtquick-window-window-pro.html">window/window.pro</a></li>
<li><a href="qtquick-window-window-qml.html">window/window.qml</a></li>
<li><a href="qtquick-window-window-qrc.html">window/window.qrc</a></li>
</ul>
<p>Images:</p>
<ul>
<li><a href="images/used-in-examples/window/resources/icon64.png">window/resources/icon64.png</a></li>
</ul>
</div>
<!-- @@@window -->
        </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>