Sophie

Sophie

distrib > Mageia > 6 > i586 > by-pkgid > f93881942bd3805980c2fe63aa853d78 > files > 201

qtdoc5-5.9.4-1.mga6.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" />
<!-- portingcppapps_toqt5.qdoc -->
  <title>Porting C++ Applications to Qt 5 | Qt 5.9</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 ><a href="index.html">Qt 5.9</a></td><td >Porting C++ Applications to Qt 5</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</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="#related-topics">Related Topics</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Porting C++ Applications to Qt 5</h1>
<span class="subtitle"></span>
<!-- $$$portingcppapp.html-description -->
<div class="descr"> <a name="details"></a>
<p>This topic talks about the Qt Widgets changes in Qt 5. The following step-by-step instructions take you through the changes required to port the Animated Tiles application to Qt 5:</p>
<ol class="1" type="1"><li>Open the Animated Tiles project using Qt Creator.</li>
<li>Edit <code>main.cpp</code> and replace the <code>#include &lt;QtGui&gt;</code> instance with <code>#include &lt;QtWidgets&gt;</code>. The Perl-script <code>fixqt4headers.pl</code> can be used to scan the source files of a project and perform the replacements.</li>
<li>Edit the <code>animatedtiles.pro</code> and add <code>QT += widgets</code> towards the end of the file.<p><b>Note: </b>Qt GUI is included by default in all Qt applications unless excluded using the <code>QT -= gui</code> directive in the <code>qmake</code> project file.</p></li>
<li>Save the changes and run the application.</li>
</ol>
<p>Once you see the application running, check whether it behaves as expected.</p>
<p class="centerAlign"><img src="images/animatedtiles_snapshot.png" alt="&quot;A snapshot of the \c animatedtiles application running on Ubuntu v12.04&quot;" /></p><p>It is also possible to keep the project compiling with Qt 4 and Qt 5. This requires:</p>
<ol class="1" type="1"><li>Omitting the module name from all includes by running the <code>fixqt4headers.pl</code> script with the <code>--strip-modules</code> option.</li>
<li>Adding scopes depending on the version of Qt to the <code>.pro</code> files:<pre class="cpp">

  greaterThan(QT_MAJOR_VERSION<span class="operator">,</span> <span class="number">4</span>): QT <span class="operator">+</span><span class="operator">=</span> widgets

</pre>
</li>
<li>Introducing <code>#if</code> scopes around code using modified API:<pre class="cpp">

  <span class="preprocessor">#if QT_VERSION &gt;= 0x050000</span>
      headerView<span class="operator">-</span><span class="operator">&gt;</span>setSectionResizeMode(<span class="type">QHeaderView</span><span class="operator">::</span>ResizeToContents);
  <span class="preprocessor">#else</span>
      headerView<span class="operator">-</span><span class="operator">&gt;</span>setResizeMode(<span class="type">QHeaderView</span><span class="operator">::</span>ResizeToContents);
  <span class="preprocessor">#endif</span>

</pre>
</li>
</ol>
<p>if you are using Qt WebKit, see Qt WebKit to Qt WebEngine porting instructions.</p>
<a name="related-topics"></a>
<h2 id="related-topics">Related Topics</h2>
<ul>
<li><a href="sourcebreaks.html">C++ API Changes</a></li>
<li><a href="portingqmlapp.html">Porting QML Applications to Qt 5 Example</a></li>
<li><a href="qtexamplesandtutorials.html">Qt Examples And Tutorials</a></li>
</ul>
</div>
<!-- @@@portingcppapp.html -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 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>