CopperSpice API  1.9.2
QVBoxLayout Class Reference

The QVBoxLayout class lines up widgets vertically. More...

Inheritance diagram for QVBoxLayout:
QBoxLayout QLayout QObject QLayoutItem

Public Methods

 QVBoxLayout ()
 
 QVBoxLayout (QWidget *parent)
 
 ~QVBoxLayout ()
 
- Public Methods inherited from QBoxLayout
 QBoxLayout (Direction direction, QWidget *parent=nullptr)
 
 ~QBoxLayout ()
 
void addItem (QLayoutItem *item) override
 
void addLayout (QLayout *layout, int stretch=0)
 
void addSpacerItem (QSpacerItem *spacerItem)
 
void addSpacing (int size)
 
void addStretch (int stretch=0)
 
void addStrut (int size)
 
void addWidget (QWidget *widget, int stretch=0, Qt::Alignment alignment=Qt::Alignment ())
 
int count () const override
 
Direction direction () const
 
Qt::Orientations expandingDirections () const override
 
bool hasHeightForWidth () const override
 
int heightForWidth (int width) const override
 
void insertItem (int index, QLayoutItem *item)
 
void insertLayout (int index, QLayout *layout, int stretch=0)
 
void insertSpacerItem (int index, QSpacerItem *spacerItem)
 
void insertSpacing (int index, int size)
 
void insertStretch (int index, int stretch=0)
 
void insertWidget (int index, QWidget *widget, int stretch=0, Qt::Alignment alignment=Qt::Alignment ())
 
void invalidate () override
 
QLayoutItemitemAt (int index) const override
 
QSize maximumSize () const override
 
int minimumHeightForWidth (int width) const override
 
QSize minimumSize () const override
 
void setDirection (Direction direction)
 
void setGeometry (const QRect &rect) override
 
void setSpacing (int spacing)
 
void setStretch (int index, int stretch)
 
bool setStretchFactor (QLayout *layout, int stretch)
 
bool setStretchFactor (QWidget *widget, int stretch)
 
QSize sizeHint () const override
 
int spacing () const
 
int stretch (int index) const
 
QLayoutItemtakeAt (int index) override
 
- Public Methods inherited from QLayout
 QLayout ()
 
 QLayout (QWidget *parent)
 
bool activate ()
 
void addWidget (QWidget *w)
 
QMargins contentsMargins () const
 
QRect contentsRect () const
 
QSizePolicy::ControlTypes controlTypes () const override
 
Qt::Orientations expandingDirections () const override
 
QRect geometry () const override
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 
virtual int indexOf (QWidget *widget) const
 
void invalidate () override
 
bool isEmpty () const override
 
bool isEnabled () const
 
QLayout * layout () override
 
int margin () const
 
QSize maximumSize () const override
 
QWidgetmenuBar () const
 
QSize minimumSize () const override
 
QWidgetparentWidget () const
 
void removeItem (QLayoutItem *item)
 
void removeWidget (QWidget *widget)
 
virtual QLayoutItemreplaceWidget (QWidget *from, QWidget *to, Qt::FindChildOptions options=Qt::FindChildrenRecursively)
 
bool setAlignment (QLayout *layout, Qt::Alignment alignment)
 
void setAlignment (Qt::Alignment alignment)
 
bool setAlignment (QWidget *widget, Qt::Alignment alignment)
 
void setContentsMargins (const QMargins &margins)
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setEnabled (bool enable)
 
void setGeometry (const QRect &rect) override
 
void setMargin (int margin)
 
void setMenuBar (QWidget *widget)
 
void setSizeConstraint (SizeConstraint constraint)
 
void setSpacing (int spacing)
 
SizeConstraint sizeConstraint () const
 
int spacing () const
 
void update ()
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 
- Public Methods inherited from QLayoutItem
 QLayoutItem (Qt::Alignment alignment=Qt::Alignment ())
 
virtual ~QLayoutItem ()
 
Qt::Alignment alignment () const
 
void setAlignment (Qt::Alignment alignment)
 
virtual QSpacerItemspacerItem ()
 
virtual QWidgetwidget ()
 

Additional Inherited Members

- Public Types inherited from QBoxLayout
enum  Direction
 
- Public Types inherited from QLayout
enum  SizeConstraint
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QLayout
static QSize closestAcceptableSize (const QWidget *widget, const QSize &size)
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QLayout
void addChildLayout (QLayout *layout)
 
void addChildWidget (QWidget *widget)
 
QRect alignmentRect (const QRect &rect) const
 
void childEvent (QChildEvent *event) override
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QLayout
 margin
 
 sizeConstraint
 
 spacing
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The QVBoxLayout class lines up widgets vertically. This class is used to construct vertically box layout objects. Refer to QBoxLayout for additional details.

Example

The example shown below is the simplest use of this class.

The first five lines create the widgets which will be used in the layout. Then a new QVBoxLayout is created and the widgets are added into the layout. The last step is to call QWidget::setLayout() to install the QVBoxLayout object onto the widget. At that point the widgets in the layout are changed to have window as their parent.

Horizontal box layout with five child widgets
QWidget *window = new QWidget;
QPushButton *button1 = new QPushButton("One");
QPushButton *button2 = new QPushButton("Two");
QPushButton *button3 = new QPushButton("Three");
QPushButton *button4 = new QPushButton("Four");
QPushButton *button5 = new QPushButton("Five");
layout->addWidget(button1);
layout->addWidget(button2);
layout->addWidget(button3);
layout->addWidget(button4);
layout->addWidget(button5);
window->setLayout(layout);
window->show();
See also
QHBoxLayout, QGridLayout, QStackedLayout, Layout Management

Constructor & Destructor Documentation

QVBoxLayout::QVBoxLayout ( )

Constructs a new vertical box layout. This QVBoxLayout must be added to another layout to have any effect.

QVBoxLayout::QVBoxLayout ( QWidget parent)
explicit

Constructs a new vertical box with the given parent.

QVBoxLayout::~QVBoxLayout ( )

Destroys this box layout. The widgets controlled by this layout are not destroyed.