Krita Source Code Documentation
Loading...
Searching...
No Matches
KoVBox Class Reference

#include <KoVBox.h>

+ Inheritance diagram for KoVBox:

Public Member Functions

 KoVBox (QWidget *parent=0)
 
QSize minimumSizeHint () const override
 
void setMargin (int margin)
 
void setSpacing (int space)
 
void setStretchFactor (QWidget *widget, int stretch)
 
QSize sizeHint () const override
 
 ~KoVBox () override
 

Protected Member Functions

void childEvent (QChildEvent *ev) override
 

Private Attributes

Private *const d
 

Friends

class Private
 

Detailed Description

A container widget which arranges its children vertically.

When using a KoVBox you don't need to create a layout nor to add the child widgets to it.

Both margin and spacing are initialized to 0. Use QHBoxLayout if you need standard layout margins.

See also
KVBox

Definition at line 27 of file KoVBox.h.

Constructor & Destructor Documentation

◆ KoVBox()

KoVBox::KoVBox ( QWidget * parent = 0)
explicit

Creates a new hbox.

Definition at line 13 of file KoVBox.cpp.

14 : QFrame(parent),
15 d(0)
16{
17 QVBoxLayout *layout = new QVBoxLayout(this);
18 layout->setSpacing(0);
19 layout->setContentsMargins(0, 0, 0, 0);
20}
Private *const d
Definition KoVBox.h:76

◆ ~KoVBox()

KoVBox::~KoVBox ( )
override

Destructor.

Definition at line 22 of file KoVBox.cpp.

23{
24}

Member Function Documentation

◆ childEvent()

void KoVBox::childEvent ( QChildEvent * ev)
overrideprotected

Definition at line 26 of file KoVBox.cpp.

27{
28 switch (event->type()) {
29 case QEvent::ChildAdded: {
30 QChildEvent *childEvent = static_cast<QChildEvent *>(event);
31 if (childEvent->child()->isWidgetType()) {
32 QWidget *widget = static_cast<QWidget *>(childEvent->child());
33 static_cast<QBoxLayout *>(layout())->addWidget(widget);
34 }
35
36 break;
37 }
38 case QEvent::ChildRemoved: {
39 QChildEvent *childEvent = static_cast<QChildEvent *>(event);
40 if (childEvent->child()->isWidgetType()) {
41 QWidget *widget = static_cast<QWidget *>(childEvent->child());
42 static_cast<QBoxLayout *>(layout())->removeWidget(widget);
43 }
44
45 break;
46 }
47 default:
48 break;
49 }
50 QFrame::childEvent(event);
51}
void childEvent(QChildEvent *ev) override
Definition KoVBox.cpp:26

References childEvent().

◆ minimumSizeHint()

QSize KoVBox::minimumSizeHint ( ) const
override

Calculate the recommended minimum size for this hbox.

Definition at line 61 of file KoVBox.cpp.

62{
63 KoVBox *that = const_cast<KoVBox *>(this);
64 QApplication::sendPostedEvents(that, QEvent::ChildAdded);
65
66 return QFrame::minimumSizeHint();
67}

◆ setMargin()

void KoVBox::setMargin ( int margin)

Sets the margin of the hbox.

Definition at line 79 of file KoVBox.cpp.

80{
81 layout()->setContentsMargins(margin, margin, margin, margin);
82}

◆ setSpacing()

void KoVBox::setSpacing ( int space)

Sets the spacing between the child widgets to space.

To get the default layout spacing, set space to -1.

Definition at line 69 of file KoVBox.cpp.

70{
71 layout()->setSpacing(spacing);
72}

◆ setStretchFactor()

void KoVBox::setStretchFactor ( QWidget * widget,
int stretch )

Sets the stretch factor of widget to stretch.

Definition at line 74 of file KoVBox.cpp.

75{
76 static_cast<QBoxLayout *>(layout())->setStretchFactor(widget, stretch);
77}
void setStretchFactor(QWidget *widget, int stretch)
Definition KoVBox.cpp:74

References setStretchFactor().

◆ sizeHint()

QSize KoVBox::sizeHint ( ) const
override

Calculate the recommended size for this hbox.

Definition at line 53 of file KoVBox.cpp.

54{
55 KoVBox *that = const_cast<KoVBox *>(this);
56 QApplication::sendPostedEvents(that, QEvent::ChildAdded);
57
58 return QFrame::sizeHint();
59}

Friends And Related Symbol Documentation

◆ Private

friend class Private
friend

Definition at line 75 of file KoVBox.h.

Member Data Documentation

◆ d

Private* const KoVBox::d
private

Definition at line 76 of file KoVBox.h.


The documentation for this class was generated from the following files: