<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- abstractformbuilder.cpp --> <title>QAbstractFormBuilder Class | Qt Designer Manual</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.9</td><td ><a href="qtdesigner-manual.html">Qt Designer Manual</a></td><td ><a href="qtdesigner-module.html">C++ Classes</a></td><td >QAbstractFormBuilder</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="#public-functions">Public 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">QAbstractFormBuilder Class</h1> <!-- $$$QAbstractFormBuilder-brief --> <p>The <a href="qabstractformbuilder.html">QAbstractFormBuilder</a> class provides a default implementation for classes that create user interfaces at run-time. <a href="#details">More...</a></p> <!-- @@@QAbstractFormBuilder --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QAbstractFormBuilder></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += designer</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><a href="qformbuilder.html">QFormBuilder</a></p> </td></tr></table></div><ul> <li><a href="qabstractformbuilder-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="qabstractformbuilder.html#QAbstractFormBuilder">QAbstractFormBuilder</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qabstractformbuilder.html#dtor.QAbstractFormBuilder">~QAbstractFormBuilder</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qabstractformbuilder.html#errorString">errorString</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QWidget *</td><td class="memItemRight bottomAlign"><b><a href="qabstractformbuilder.html#load">load</a></b>(QIODevice *<i>device</i>, QWidget *<i>parent</i> = Q_NULLPTR)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qabstractformbuilder.html#save">save</a></b>(QIODevice *<i>device</i>, QWidget *<i>widget</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qabstractformbuilder.html#setWorkingDirectory">setWorkingDirectory</a></b>(const QDir &<i>directory</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QDir </td><td class="memItemRight bottomAlign"><b><a href="qabstractformbuilder.html#workingDirectory">workingDirectory</a></b>() const</td></tr> </table></div> <a name="details"></a> <!-- $$$QAbstractFormBuilder-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qabstractformbuilder.html">QAbstractFormBuilder</a> class provides a default implementation for classes that create user interfaces at run-time.</p> <p><a href="qabstractformbuilder.html">QAbstractFormBuilder</a> provides a standard interface and a default implementation for constructing forms from user interface files. It is not intended to be instantiated directly. Use the <a href="qformbuilder.html">QFormBuilder</a> class to create user interfaces from UI files at run-time. For example:</p> <pre class="cpp"> MyForm<span class="operator">::</span>MyForm(<span class="type">QWidget</span> <span class="operator">*</span>parent) : <span class="type">QWidget</span>(parent) { <span class="type"><a href="qformbuilder.html">QFormBuilder</a></span> builder; <span class="type">QFile</span> file(<span class="string">":/forms/myWidget.ui"</span>); file<span class="operator">.</span>open(<span class="type">QFile</span><span class="operator">::</span>ReadOnly); <span class="type">QWidget</span> <span class="operator">*</span>myWidget <span class="operator">=</span> builder<span class="operator">.</span>load(<span class="operator">&</span>file<span class="operator">,</span> <span class="keyword">this</span>); file<span class="operator">.</span>close(); <span class="type">QVBoxLayout</span> <span class="operator">*</span>layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QVBoxLayout</span>; layout<span class="operator">-</span><span class="operator">></span>addWidget(myWidget); setLayout(layout); } </pre> <p>To override certain aspects of the form builder's behavior, subclass <a href="qabstractformbuilder.html">QAbstractFormBuilder</a> and reimplement the relevant virtual functions:</p> <ul> <li><a href="qabstractformbuilder.html#load">load</a>() handles reading of UI format files from arbitrary QIODevices, and construction of widgets from the XML data that they contain.</li> <li><a href="qabstractformbuilder.html#save">save</a>() handles saving of widget details in UI format to arbitrary QIODevices.</li> <li><a href="qabstractformbuilder.html#workingDirectory">workingDirectory</a>() and <a href="qabstractformbuilder.html#setWorkingDirectory">setWorkingDirectory</a>() control the directory in which forms are held. The form builder looks for other resources on paths relative to this directory.</li> </ul> <p>The <a href="qformbuilder.html">QFormBuilder</a> class is typically used by custom components and applications that embed <i>Qt Designer</i>. Standalone applications that need to dynamically generate user interfaces at run-time use the QUiLoader, found in the Qt UI Tools module.</p> </div> <p><b>See also </b>Qt UI Tools.</p> <!-- @@@QAbstractFormBuilder --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QAbstractFormBuilder[overload1]$$$QAbstractFormBuilder --> <h3 class="fn" id="QAbstractFormBuilder"><a name="QAbstractFormBuilder"></a>QAbstractFormBuilder::<span class="name">QAbstractFormBuilder</span>()</h3> <p>Constructs a new form builder.</p> <!-- @@@QAbstractFormBuilder --> <!-- $$$~QAbstractFormBuilder[overload1]$$$~QAbstractFormBuilder --> <h3 class="fn" id="dtor.QAbstractFormBuilder"><a name="dtor.QAbstractFormBuilder"></a><code>[virtual] </code>QAbstractFormBuilder::<span class="name">~QAbstractFormBuilder</span>()</h3> <p>Destroys the form builder.</p> <!-- @@@~QAbstractFormBuilder --> <!-- $$$errorString[overload1]$$$errorString --> <h3 class="fn" id="errorString"><a name="errorString"></a><span class="type">QString</span> QAbstractFormBuilder::<span class="name">errorString</span>() const</h3> <p>Returns a human-readable description of the last error occurred in <a href="qabstractformbuilder.html#load">load</a>().</p> <p>This function was introduced in Qt 5.0.</p> <p><b>See also </b><a href="qabstractformbuilder.html#load">load</a>().</p> <!-- @@@errorString --> <!-- $$$load[overload1]$$$loadQIODevice*QWidget* --> <h3 class="fn" id="load"><a name="load"></a><code>[virtual] </code><span class="type">QWidget</span> *QAbstractFormBuilder::<span class="name">load</span>(<span class="type">QIODevice</span> *<i>device</i>, <span class="type">QWidget</span> *<i>parent</i> = Q_NULLPTR)</h3> <p>Loads an XML representation of a widget from the given <i>device</i>, and constructs a new widget with the specified <i>parent</i>.</p> <p><b>See also </b><a href="qabstractformbuilder.html#save">save</a>() and <a href="qabstractformbuilder.html#errorString">errorString</a>().</p> <!-- @@@load --> <!-- $$$save[overload1]$$$saveQIODevice*QWidget* --> <h3 class="fn" id="save"><a name="save"></a><code>[virtual] </code><span class="type">void</span> QAbstractFormBuilder::<span class="name">save</span>(<span class="type">QIODevice</span> *<i>device</i>, <span class="type">QWidget</span> *<i>widget</i>)</h3> <p>Saves an XML representation of the given <i>widget</i> to the specified <i>device</i> in the standard UI file format.</p> <p><b>See also </b><a href="qabstractformbuilder.html#load">load</a>().</p> <!-- @@@save --> <!-- $$$setWorkingDirectory[overload1]$$$setWorkingDirectoryconstQDir& --> <h3 class="fn" id="setWorkingDirectory"><a name="setWorkingDirectory"></a><span class="type">void</span> QAbstractFormBuilder::<span class="name">setWorkingDirectory</span>(const <span class="type">QDir</span> &<i>directory</i>)</h3> <p>Sets the current working directory of the form builder to the specified <i>directory</i>.</p> <p><b>See also </b><a href="qabstractformbuilder.html#workingDirectory">workingDirectory</a>().</p> <!-- @@@setWorkingDirectory --> <!-- $$$workingDirectory[overload1]$$$workingDirectory --> <h3 class="fn" id="workingDirectory"><a name="workingDirectory"></a><span class="type">QDir</span> QAbstractFormBuilder::<span class="name">workingDirectory</span>() const</h3> <p>Returns the current working directory of the form builder.</p> <p><b>See also </b><a href="qabstractformbuilder.html#setWorkingDirectory">setWorkingDirectory</a>().</p> <!-- @@@workingDirectory --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</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>