<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qqmlincubator.cpp --> <title>QQmlIncubationController Class | Qt QML 5.11</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="../qtdoc/index.html">Qt 5.11</a></td><td ><a href="qtqml-index.html">Qt QML</a></td><td ><a href="qtqml-module.html">C++ Classes</a></td><td >QQmlIncubationController</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.11.2 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="#public-functions">Public Functions</a></li> <li class="level1"><a href="#protected-functions">Protected Functions</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">QQmlIncubationController Class</h1> <!-- $$$QQmlIncubationController-brief --> <p><a href="qqmlincubationcontroller.html">QQmlIncubationController</a> instances drive the progress of QQmlIncubators. <a href="#details">More...</a></p> <!-- @@@QQmlIncubationController --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QQmlIncubationController></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += qml</td></tr></table></div><ul> <li><a href="qqmlincubationcontroller-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlincubationcontroller.html#QQmlIncubationController">QQmlIncubationController</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QQmlEngine *</td><td class="memItemRight bottomAlign"><b><a href="qqmlincubationcontroller.html#engine">engine</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlincubationcontroller.html#incubateFor">incubateFor</a></b>(int <i>msecs</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlincubationcontroller.html#incubateWhile">incubateWhile</a></b>(volatile bool *<i>flag</i>, int <i>msecs</i> = 0)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlincubationcontroller.html#incubatingObjectCount">incubatingObjectCount</a></b>() const</td></tr> </table></div> <a name="protected-functions"></a> <h2 id="protected-functions">Protected Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qqmlincubationcontroller.html#incubatingObjectCountChanged">incubatingObjectCountChanged</a></b>(int <i>incubatingObjectCount</i>)</td></tr> </table></div> <a name="details"></a> <!-- $$$QQmlIncubationController-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p><a href="qqmlincubationcontroller.html">QQmlIncubationController</a> instances drive the progress of QQmlIncubators.</p> <p>In order to behave asynchronously and not introduce stutters or freezes in an application, the process of creating objects a QQmlIncubators must be driven only during the application's idle time. <a href="qqmlincubationcontroller.html">QQmlIncubationController</a> allows the application to control exactly when, how often and for how long this processing occurs.</p> <p>A <a href="qqmlincubationcontroller.html">QQmlIncubationController</a> derived instance should be created and set on a <a href="qqmlengine.html">QQmlEngine</a> by calling the <a href="qqmlengine.html#setIncubationController">QQmlEngine::setIncubationController</a>() method. Processing is then controlled by calling the <a href="qqmlincubationcontroller.html#incubateFor">QQmlIncubationController::incubateFor</a>() or <a href="qqmlincubationcontroller.html#incubateWhile">QQmlIncubationController::incubateWhile</a>() methods as dictated by the application's requirements.</p> <p>For example, this is an example of a incubation controller that will incubate for a maximum of 5 milliseconds out of every 16 milliseconds.</p> <pre class="cpp"> <span class="keyword">class</span> PeriodicIncubationController : <span class="keyword">public</span> <span class="type"><a href="../qtcore/qobject.html">QObject</a></span><span class="operator">,</span> <span class="keyword">public</span> <span class="type"><a href="qqmlincubationcontroller.html#QQmlIncubationController">QQmlIncubationController</a></span> { <span class="keyword">public</span>: PeriodicIncubationController() { startTimer(<span class="number">16</span>); } <span class="keyword">protected</span>: <span class="type">void</span> timerEvent(<span class="type"><a href="../qtcore/qtimerevent.html">QTimerEvent</a></span> <span class="operator">*</span>) override { incubateFor(<span class="number">5</span>); } }; </pre> <p>Although the previous example would work, it is not optimal. Real world incubation controllers should try and maximize the amount of idle time they consume - rather than a static amount like 5 milliseconds - while not disturbing the application.</p> </div> <!-- @@@QQmlIncubationController --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QQmlIncubationController[overload1]$$$QQmlIncubationController --> <h3 class="fn" id="QQmlIncubationController"><a name="QQmlIncubationController"></a>QQmlIncubationController::<span class="name">QQmlIncubationController</span>()</h3> <p>Create a new incubation controller.</p> <!-- @@@QQmlIncubationController --> <!-- $$$engine[overload1]$$$engine --> <h3 class="fn" id="engine"><a name="engine"></a><span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> *QQmlIncubationController::<span class="name">engine</span>() const</h3> <p>Return the <a href="qqmlengine.html">QQmlEngine</a> this incubation controller is set on, or 0 if it has not been set on any engine.</p> <!-- @@@engine --> <!-- $$$incubateFor[overload1]$$$incubateForint --> <h3 class="fn" id="incubateFor"><a name="incubateFor"></a><span class="type">void</span> QQmlIncubationController::<span class="name">incubateFor</span>(<span class="type">int</span> <i>msecs</i>)</h3> <p>Incubate objects for <i>msecs</i>, or until there are no more objects to incubate.</p> <!-- @@@incubateFor --> <!-- $$$incubateWhile[overload1]$$$incubateWhilevolatilebool*int --> <h3 class="fn" id="incubateWhile"><a name="incubateWhile"></a><span class="type">void</span> QQmlIncubationController::<span class="name">incubateWhile</span>(<span class="type">volatile</span> <span class="type">bool</span> *<i>flag</i>, <span class="type">int</span> <i>msecs</i> = 0)</h3> <p>Incubate objects while the bool pointed to by <i>flag</i> is true, or until there are no more objects to incubate, or up to <i>msecs</i> if <i>msecs</i> is not zero.</p> <p>Generally this method is used in conjunction with a thread or a UNIX signal that sets the bool pointed to by <i>flag</i> to false when it wants incubation to be interrupted.</p> <!-- @@@incubateWhile --> <!-- $$$incubatingObjectCount[overload1]$$$incubatingObjectCount --> <h3 class="fn" id="incubatingObjectCount"><a name="incubatingObjectCount"></a><span class="type">int</span> QQmlIncubationController::<span class="name">incubatingObjectCount</span>() const</h3> <p>Return the number of objects currently incubating.</p> <!-- @@@incubatingObjectCount --> <!-- $$$incubatingObjectCountChanged[overload1]$$$incubatingObjectCountChangedint --> <h3 class="fn" id="incubatingObjectCountChanged"><a name="incubatingObjectCountChanged"></a><code>[virtual protected] </code><span class="type">void</span> QQmlIncubationController::<span class="name">incubatingObjectCountChanged</span>(<span class="type">int</span> <i>incubatingObjectCount</i>)</h3> <p>Called when the number of incubating objects changes. <i>incubatingObjectCount</i> is the new number of incubating objects.</p> <p>The default implementation does nothing.</p> <!-- @@@incubatingObjectCountChanged --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2018 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>