<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qboxlayout.cpp --> <title>QVBoxLayout Class | 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 ><a href="qtwidgets-module.html">C++ Classes</a></td><td >QVBoxLayout</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="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="#static-public-members">Static Public Members</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">QVBoxLayout Class</h1> <!-- $$$QVBoxLayout-brief --> <p>The <a href="qvboxlayout.html">QVBoxLayout</a> class lines up widgets vertically. <a href="#details">More...</a></p> <!-- @@@QVBoxLayout --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QVBoxLayout></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += widgets</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qboxlayout.html">QBoxLayout</a></td></tr></table></div><ul> <li><a href="qvboxlayout-members.html">List of all members, including inherited members</a></li> <li><a href="qvboxlayout-obsolete.html">Obsolete 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="qvboxlayout.html#QVBoxLayout">QVBoxLayout</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvboxlayout.html#QVBoxLayout-1">QVBoxLayout</a></b>(QWidget *<i>parent</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qvboxlayout.html#dtor.QVBoxLayout">~QVBoxLayout</a></b>()</td></tr> </table></div> <ul> <li class="fn">33 public functions inherited from <a href="qboxlayout.html#public-functions">QBoxLayout</a></li> <li class="fn">37 public functions inherited from <a href="qlayout.html#public-functions">QLayout</a></li> <li class="fn">31 public functions inherited from <a href="../qtcore/qobject.html#public-functions">QObject</a></li> <li class="fn">17 public functions inherited from <a href="qlayoutitem.html#public-functions">QLayoutItem</a></li> </ul> <a name="static-public-members"></a> <h2 id="static-public-members">Static Public Members</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qvboxlayout.html#staticMetaObject-var">staticMetaObject</a></b></td></tr> </table></div> <ul> <li class="fn">1 static public member inherited from <a href="qlayout.html#static-public-members">QLayout</a></li> <li class="fn">9 static public members inherited from <a href="../qtcore/qobject.html#static-public-members">QObject</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li class="fn">2 properties inherited from <a href="qlayout.html#properties">QLayout</a></li> <li class="fn">1 property inherited from <a href="../qtcore/qobject.html#properties">QObject</a></li> <li class="fn">1 public slot inherited from <a href="../qtcore/qobject.html#public-slots">QObject</a></li> <li class="fn">2 signals inherited from <a href="../qtcore/qobject.html#signals">QObject</a></li> <li class="fn">4 protected functions inherited from <a href="qlayout.html#protected-functions">QLayout</a></li> <li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li> </ul> <a name="details"></a> <!-- $$$QVBoxLayout-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qvboxlayout.html">QVBoxLayout</a> class lines up widgets vertically.</p> <p>This class is used to construct vertical box layout objects. See <a href="qboxlayout.html">QBoxLayout</a> for details.</p> <p>The simplest use of the class is like this:</p> <pre class="cpp"> <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>window <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qwidget.html">QWidget</a></span>; <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>button1 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(<span class="string">"One"</span>); <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>button2 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(<span class="string">"Two"</span>); <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>button3 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(<span class="string">"Three"</span>); <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>button4 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(<span class="string">"Four"</span>); <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>button5 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qpushbutton.html">QPushButton</a></span>(<span class="string">"Five"</span>); <span class="type"><a href="qvboxlayout.html#QVBoxLayout">QVBoxLayout</a></span> <span class="operator">*</span>layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html#QVBoxLayout">QVBoxLayout</a></span>; layout<span class="operator">-</span><span class="operator">></span>addWidget(button1); layout<span class="operator">-</span><span class="operator">></span>addWidget(button2); layout<span class="operator">-</span><span class="operator">></span>addWidget(button3); layout<span class="operator">-</span><span class="operator">></span>addWidget(button4); layout<span class="operator">-</span><span class="operator">></span>addWidget(button5); window<span class="operator">-</span><span class="operator">></span>setLayout(layout); window<span class="operator">-</span><span class="operator">></span>show(); </pre> <p>First, we create the widgets we want in the layout. Then, we create the <a href="qvboxlayout.html">QVBoxLayout</a> object and add the widgets into the layout. Finally, we call <a href="qwidget.html#setLayout">QWidget::setLayout</a>() to install the <a href="qvboxlayout.html">QVBoxLayout</a> object onto the widget. At that point, the widgets in the layout are reparented to have <code>window</code> as their parent.</p> <p class="centerAlign"><img src="images/qvboxlayout-with-5-children.png" alt="Horizontal box layout with five child widgets" /></p></div> <p><b>See also </b><a href="qhboxlayout.html">QHBoxLayout</a>, <a href="qgridlayout.html">QGridLayout</a>, <a href="qstackedlayout.html">QStackedLayout</a>, <a href="layout.html">Layout Management</a>, and <a href="qtwidgets-layouts-basiclayouts-example.html">Basic Layouts Example</a>.</p> <!-- @@@QVBoxLayout --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QVBoxLayout[overload1]$$$QVBoxLayout --> <h3 class="fn" id="QVBoxLayout"><a name="QVBoxLayout"></a>QVBoxLayout::<span class="name">QVBoxLayout</span>()</h3> <p>Constructs a new vertical box. You must add it to another layout.</p> <!-- @@@QVBoxLayout --> <!-- $$$QVBoxLayout$$$QVBoxLayoutQWidget* --> <h3 class="fn" id="QVBoxLayout-1"><a name="QVBoxLayout-1"></a>QVBoxLayout::<span class="name">QVBoxLayout</span>(<span class="type"><a href="qwidget.html">QWidget</a></span> *<i>parent</i>)</h3> <p>Constructs a new top-level vertical box with parent <i>parent</i>.</p> <!-- @@@QVBoxLayout --> <!-- $$$~QVBoxLayout[overload1]$$$~QVBoxLayout --> <h3 class="fn" id="dtor.QVBoxLayout"><a name="dtor.QVBoxLayout"></a><code>[virtual] </code>QVBoxLayout::<span class="name">~QVBoxLayout</span>()</h3> <p>Destroys this box layout.</p> <p>The layout's widgets aren't destroyed.</p> <!-- @@@~QVBoxLayout --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</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>