• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • widgets
khbox.cpp
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 Copyright (C) 2005 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18
19#include "khbox.h"
20
21#include <QtCore/QEvent>
22#include <QtGui/QApplication>
23#include <QtGui/QHBoxLayout>
24#include <QtGui/QVBoxLayout>
25
26KHBox::KHBox( QWidget* parent )
27 : QFrame( parent ),
28 d( 0 )
29{
30 QHBoxLayout* layout = new QHBoxLayout( this );
31 layout->setSpacing( 0 );
32 layout->setMargin( 0 );
33
34 setLayout( layout );
35}
36
37
38KHBox::KHBox( bool /*vertical*/, QWidget* parent )
39 : QFrame( parent ),
40 d( 0 )
41{
42 QVBoxLayout* layout = new QVBoxLayout( this );
43 layout->setSpacing( 0 );
44 layout->setMargin( 0 );
45
46 setLayout( layout );
47}
48
49KHBox::~KHBox()
50{
51}
52
53void KHBox::childEvent( QChildEvent* event )
54{
55 switch ( event->type() ) {
56 case QEvent::ChildAdded:
57 {
58 QChildEvent* childEvent = static_cast<QChildEvent *>( event );
59 if ( childEvent->child()->isWidgetType() ) {
60 QWidget* widget = static_cast<QWidget *>( childEvent->child() );
61 static_cast<QBoxLayout *>( layout() )->addWidget( widget );
62 }
63
64 break;
65 }
66 case QEvent::ChildRemoved:
67 {
68 QChildEvent* childEvent = static_cast<QChildEvent *>( event );
69 if ( childEvent->child()->isWidgetType() ) {
70 QWidget* widget = static_cast<QWidget *>( childEvent->child() );
71 static_cast<QBoxLayout *>( layout() )->removeWidget( widget );
72 }
73
74 break;
75 }
76 default:
77 break;
78 }
79 QFrame::childEvent(event);
80}
81
82QSize KHBox::sizeHint() const
83{
84 KHBox* that = const_cast<KHBox *>( this );
85 QApplication::sendPostedEvents( that, QEvent::ChildAdded );
86
87 return QFrame::sizeHint();
88}
89
90QSize KHBox::minimumSizeHint() const
91{
92 KHBox* that = const_cast<KHBox *>( this );
93 QApplication::sendPostedEvents( that, QEvent::ChildAdded );
94
95 return QFrame::minimumSizeHint();
96}
97
98void KHBox::setSpacing( int spacing )
99{
100 layout()->setSpacing( spacing );
101}
102
103void KHBox::setStretchFactor( QWidget* widget, int stretch )
104{
105 static_cast<QBoxLayout *>( layout() )->setStretchFactor( widget, stretch );
106}
107
108void KHBox::setMargin( int margin )
109{
110 layout()->setMargin( margin );
111}
112
113#include "khbox.moc"
KHBox
A container widget which arranges its children horizontally.
Definition: khbox.h:41
KHBox::childEvent
virtual void childEvent(QChildEvent *ev)
Definition: khbox.cpp:53
KHBox::KHBox
KHBox(QWidget *parent=0)
Creates a new hbox.
Definition: khbox.cpp:26
KHBox::sizeHint
virtual QSize sizeHint() const
Calculate the recommended size for this hbox.
Definition: khbox.cpp:82
KHBox::setStretchFactor
void setStretchFactor(QWidget *widget, int stretch)
Sets the stretch factor of widget to stretch.
Definition: khbox.cpp:103
KHBox::minimumSizeHint
virtual QSize minimumSizeHint() const
Calculate the recommended minimum size for this hbox.
Definition: khbox.cpp:90
KHBox::setMargin
void setMargin(int margin)
Sets the margin of the hbox.
Definition: khbox.cpp:108
KHBox::~KHBox
~KHBox()
Destructor.
Definition: khbox.cpp:49
KHBox::setSpacing
void setSpacing(int space)
Sets the spacing between the child widgets to space.
Definition: khbox.cpp:98
QFrame
QWidget
khbox.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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