• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • krita API Reference
  • KDE Home
  • Contact Us
 

KritaWidgets

  • sources
  • kfour-appscomplete
  • krita
  • libs
  • widgets
KoVBox.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  SPDX-FileCopyrightText: 2005 David Faure <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-only
5 */
6 
7 #include "KoVBox.h"
8 
9 #include <QEvent>
10 #include <QApplication>
11 #include <QVBoxLayout>
12 
13 KoVBox::KoVBox(QWidget *parent)
14  : QFrame(parent),
15  d(0)
16 {
17  QVBoxLayout *layout = new QVBoxLayout(this);
18  layout->setSpacing(0);
19  layout->setMargin(0);
20 }
21 
22 KoVBox::~KoVBox()
23 {
24 }
25 
26 void KoVBox::childEvent(QChildEvent *event)
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 }
52 
53 QSize KoVBox::sizeHint() const
54 {
55  KoVBox *that = const_cast<KoVBox *>(this);
56  QApplication::sendPostedEvents(that, QEvent::ChildAdded);
57 
58  return QFrame::sizeHint();
59 }
60 
61 QSize KoVBox::minimumSizeHint() const
62 {
63  KoVBox *that = const_cast<KoVBox *>(this);
64  QApplication::sendPostedEvents(that, QEvent::ChildAdded);
65 
66  return QFrame::minimumSizeHint();
67 }
68 
69 void KoVBox::setSpacing(int spacing)
70 {
71  layout()->setSpacing(spacing);
72 }
73 
74 void KoVBox::setStretchFactor(QWidget *widget, int stretch)
75 {
76  static_cast<QBoxLayout *>(layout())->setStretchFactor(widget, stretch);
77 }
78 
79 void KoVBox::setMargin(int margin)
80 {
81  layout()->setMargin(margin);
82 }
83 
KoVBox::childEvent
void childEvent(QChildEvent *ev) override
Definition: KoVBox.cpp:26
QVBoxLayout
KoVBox::minimumSizeHint
QSize minimumSizeHint() const override
Calculate the recommended minimum size for this hbox.
Definition: KoVBox.cpp:61
QCoreApplication::sendPostedEvents
void sendPostedEvents()
QFrame
QFrame::event
virtual bool event(QEvent *e)
QWidget::layout
QLayout * layout() const
KoVBox::sizeHint
QSize sizeHint() const override
Calculate the recommended size for this hbox.
Definition: KoVBox.cpp:53
QLayout::setMargin
void setMargin(int margin)
QWidget
QSize
KoVBox::~KoVBox
~KoVBox() override
Destructor.
Definition: KoVBox.cpp:22
QFrame::sizeHint
virtual QSize sizeHint() const
QChildEvent
QWidget::minimumSizeHint
virtual QSize minimumSizeHint() const
KoVBox.h
KoVBox
A container widget which arranges its children vertically.
Definition: KoVBox.h:27
KoVBox::setMargin
void setMargin(int margin)
Sets the margin of the hbox.
Definition: KoVBox.cpp:79
QObject::childEvent
virtual void childEvent(QChildEvent *event)
KoVBox::setStretchFactor
void setStretchFactor(QWidget *widget, int stretch)
Sets the stretch factor of widget to stretch.
Definition: KoVBox.cpp:74
QLayout::setSpacing
void setSpacing(int)
KoVBox::setSpacing
void setSpacing(int space)
Sets the spacing between the child widgets to space.
Definition: KoVBox.cpp:69
KoVBox::KoVBox
KoVBox(QWidget *parent=0)
Creates a new hbox.
Definition: KoVBox.cpp:13
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Jan 19 2021 23:44:00 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KritaWidgets

Skip menu "KritaWidgets"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

krita API Reference

Skip menu "krita API Reference"
  • libs
  •   KritaBasicFlakes
  •   brush
  •   KritaUndo2
  •   KritaFlake
  •   image
  •   KritaPlugin
  •   Krita
  •   KritaPigment
  •   KritaResources
  •   KritaStore
  •   ui
  •   KritaWidgets
  •   KritaWidgetUtils
  • plugins
  •   Assitants
  •   Extensions
  •   Filters
  •   Generators
  •   Formats
  •           src
  •   PaintOps
  •     libpaintop

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal