Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > d5e62c01ae8d1e579463c6a871dd44bf > files > 5019

qtbase5-doc-5.12.6-2.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" />
<!-- widgets-tutorial.qdoc -->
  <title>Widgets Tutorial - Creating a Window | Qt Widgets 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="qtwidgets-index.html">Qt Widgets</a></td><td >Widgets Tutorial - Creating a Window</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtwidgets-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="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Widgets Tutorial - Creating a Window</h1>
<span class="subtitle"></span>
<!-- $$$tutorials/widgets/toplevel-description -->
<div class="descr"> <a name="details"></a>
<p>If a widget is created without a parent, it is treated as a window, or <i>top-level widget</i>, when it is shown. Since it has no parent object to ensure that it is deleted when no longer needed, it is up to the developer to keep track of the top-level widgets in an application.</p>
<p>In the following example, we use <a href="qwidget.html">QWidget</a> to create and show a window with a default size:</p>
<div class="qt-code"><div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><pre class="cpp">

  <span class="preprocessor">#include &lt;QtWidgets&gt;</span>

  <span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>)
  {
      <span class="type"><a href="qapplication.html">QApplication</a></span> app(argc<span class="operator">,</span> argv);
      <span class="type"><a href="qwidget.html">QWidget</a></span> window;
      window<span class="operator">.</span>resize(<span class="number">320</span><span class="operator">,</span> <span class="number">240</span>);
      window<span class="operator">.</span>show();
      window<span class="operator">.</span>setWindowTitle(
          <span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">::</span>translate(<span class="string">&quot;toplevel&quot;</span><span class="operator">,</span> <span class="string">&quot;Top-level widget&quot;</span>));
      <span class="keyword">return</span> app<span class="operator">.</span>exec();
  }

</pre>
</td><td ><img src="images/widgets-tutorial-toplevel.png" alt="" /></td></tr>
</table></div>
</div><p>To create a real GUI, we need to place widgets inside the window. To do this, we pass a <a href="qwidget.html">QWidget</a> instance to a widget's constructor, as we will demonstrate in the next part of this tutorial.</p>
<p>Files:</p>
<ul>
<li><a href="qtwidgets-tutorials-widgets-toplevel-main-cpp.html">tutorials/widgets/toplevel/main.cpp</a></li>
<li><a href="qtwidgets-tutorials-widgets-toplevel-toplevel-pro.html">tutorials/widgets/toplevel/toplevel.pro</a></li>
</ul>
</div>
<!-- @@@tutorials/widgets/toplevel -->
        </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>