src/gui/kernel/qboxlayout.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.
00004 **
00005 ** This file is part of the QtGui module of the Qt Toolkit.
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://www.trolltech.com/products/qt/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00017 ** sales department at sales@trolltech.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ****************************************************************************/
00023 #include "qboxlayout.h"
00024 
00025 
00026 #include "qapplication.h"
00027 #include "qwidget.h"
00028 #include "qlist.h"
00029 #include "qsizepolicy.h"
00030 #include "qvector.h"
00031 
00032 #include "qlayoutengine_p.h"
00033 #include "qlayout_p.h"
00034 
00035 /*
00036     Returns true if the \a widget can be added to the \a layout;
00037     otherwise returns false.
00038 */
00039 static bool checkWidget(QLayout *layout, QWidget *widget)
00040 {
00041     if (!widget) {
00042         qWarning("QLayout: Cannot add null widget to %s/%s", layout->metaObject()->className(),
00043                   layout->objectName().toLocal8Bit().data());
00044         return false;
00045     }
00046     return true;
00047 }
00048 
00049 struct QBoxLayoutItem
00050 {
00051     QBoxLayoutItem(QLayoutItem *it, int stretch_ = 0)
00052         : item(it), stretch(stretch_), magic(false) { }
00053     ~QBoxLayoutItem() { delete item; }
00054 
00055     int hfw(int w) {
00056         if (item->hasHeightForWidth()) {
00057             return item->heightForWidth(w);
00058         } else {
00059             return item->sizeHint().height();
00060         }
00061     }
00062     int mhfw(int w) {
00063         if (item->hasHeightForWidth()) {
00064             return item->heightForWidth(w);
00065         } else {
00066             return item->minimumSize().height();
00067         }
00068     }
00069     int hStretch() {
00070         if (stretch == 0 && item->widget()) {
00071             return item->widget()->sizePolicy().horizontalStretch();
00072         } else {
00073             return stretch;
00074         }
00075     }
00076     int vStretch() {
00077         if (stretch == 0 && item->widget()) {
00078             return item->widget()->sizePolicy().verticalStretch();
00079         } else {
00080             return stretch;
00081         }
00082     }
00083 
00084     QLayoutItem *item;
00085     int stretch;
00086     bool magic;
00087 };
00088 
00089 class QBoxLayoutPrivate : public QLayoutPrivate
00090 {
00091     Q_DECLARE_PUBLIC(QBoxLayout)
00092 public:
00093     QBoxLayoutPrivate() : hfwWidth(-1), dirty(true) { }
00094     ~QBoxLayoutPrivate();
00095 
00096     void setDirty() {
00097         geomArray.clear();
00098         hfwWidth = -1;
00099         hfwHeight = -1;
00100         dirty = true;
00101     }
00102 
00103     QList<QBoxLayoutItem *> list;
00104     QVector<QLayoutStruct> geomArray;
00105     int hfwWidth;
00106     int hfwHeight;
00107     int hfwMinHeight;
00108     QSize sizeHint;
00109     QSize minSize;
00110     QSize maxSize;
00111     Qt::Orientations expanding;
00112     uint hasHfw : 1;
00113     uint dirty : 1;
00114     QBoxLayout::Direction dir;
00115 
00116     inline void deleteAll() { while (!list.isEmpty()) delete list.takeFirst(); }
00117 
00118     void setupGeom();
00119     void calcHfw(int);
00120 
00121 };
00122 
00123 QBoxLayoutPrivate::~QBoxLayoutPrivate()
00124 {
00125 }
00126 
00127 static inline bool horz(QBoxLayout::Direction dir)
00128 {
00129     return dir == QBoxLayout::RightToLeft || dir == QBoxLayout::LeftToRight;
00130 }
00131 
00132 /*
00133     Initializes the data structure needed by qGeomCalc and
00134     recalculates max/min and size hint.
00135 */
00136 void QBoxLayoutPrivate::setupGeom()
00137 {
00138     if (!dirty)
00139         return;
00140 
00141     Q_Q(QBoxLayout);
00142     int maxw = horz(dir) ? 0 : QLAYOUTSIZE_MAX;
00143     int maxh = horz(dir) ? QLAYOUTSIZE_MAX : 0;
00144     int minw = 0;
00145     int minh = 0;
00146     int hintw = 0;
00147     int hinth = 0;
00148 
00149     bool horexp = false;
00150     bool verexp = false;
00151 
00152     hasHfw = false;
00153 
00154     int n = list.count();
00155     geomArray.clear();
00156     QVector<QLayoutStruct> a(n);
00157 
00158     bool first = true; // empty so far?
00159     for (int i = 0; i < n; i++) {
00160         QBoxLayoutItem *box = list.at(i);
00161         QSize max = box->item->maximumSize();
00162         QSize min = box->item->minimumSize();
00163         QSize hint = box->item->sizeHint();
00164         Qt::Orientations exp = box->item->expandingDirections();
00165         bool empty = box->item->isEmpty();
00166         // space before non-empties, except the first:
00167         int space = (empty || first) ? 0 : q->spacing();
00168         bool ignore = empty && box->item->widget(); // ignore hidden widgets
00169         if (horz(dir)) {
00170             bool expand = exp & Qt::Horizontal || box->stretch > 0;
00171             horexp = horexp || expand;
00172             maxw += max.width() + space;
00173             minw += min.width() + space;
00174             hintw += hint.width() + space;
00175             if (!ignore)
00176                 qMaxExpCalc(maxh, verexp, first,
00177                             max.height(), exp & Qt::Vertical, box->item->isEmpty());
00178             minh = qMax(minh, min.height());
00179             hinth = qMax(hinth, hint.height());
00180 
00181             a[i].sizeHint = hint.width();
00182             a[i].maximumSize = max.width();
00183             a[i].minimumSize = min.width();
00184             a[i].expansive = expand;
00185             a[i].stretch = box->stretch ? box->stretch : box->hStretch();
00186         } else {
00187             bool expand = (exp & Qt::Vertical || box->stretch > 0);
00188             verexp = verexp || expand;
00189             maxh += max.height() + space;
00190             minh += min.height() + space;
00191             hinth += hint.height() + space;
00192             if (!ignore)
00193                 qMaxExpCalc(maxw, horexp, first,
00194                              max.width(), exp & Qt::Horizontal, box->item->isEmpty());
00195             minw = qMax(minw, min.width());
00196             hintw = qMax(hintw, hint.width());
00197 
00198             a[i].sizeHint = hint.height();
00199             a[i].maximumSize = max.height();
00200             a[i].minimumSize = min.height();
00201             a[i].expansive = expand;
00202             a[i].stretch = box->stretch ? box->stretch : box->vStretch();
00203         }
00204 
00205         a[i].empty = empty;
00206         hasHfw = hasHfw || box->item->hasHeightForWidth();
00207     }
00208     geomArray = a;
00209 
00210     expanding = (Qt::Orientations)
00211                        ((horexp ? Qt::Horizontal : 0)
00212                          | (verexp ? Qt::Vertical : 0));
00213 
00214     minSize = QSize(minw, minh);
00215     maxSize = QSize(maxw, maxh).expandedTo(minSize);
00216     sizeHint = QSize(hintw, hinth)
00217                      .expandedTo(minSize)
00218                      .boundedTo(maxSize);
00219 
00220     dirty = false;
00221 }
00222 
00223 /*
00224   Calculates and stores the preferred height given the width \a w.
00225 */
00226 void QBoxLayoutPrivate::calcHfw(int w)
00227 {
00228     Q_Q(QBoxLayout);
00229     int h = 0;
00230     int mh = 0;
00231 
00232     if (horz(dir)) {
00233         QVector<QLayoutStruct> &a = geomArray;
00234         int n = a.count();
00235         qGeomCalc(a, 0, n, 0, w, q->spacing());
00236         for (int i = 0; i < n; i++) {
00237             QBoxLayoutItem *box = list.at(i);
00238             h = qMax(h, box->hfw(a[i].size));
00239             mh = qMax(mh, box->mhfw(a[i].size));
00240         }
00241     } else {
00242         bool first = true;
00243         for (int i = 0; i < list.size(); ++i) {
00244             QBoxLayoutItem *box = list.at(i);
00245             bool empty = box->item->isEmpty();
00246             h += box->hfw(w);
00247             mh += box->mhfw(w);
00248             if (!first && !empty) {
00249                 h += q->spacing();
00250                 mh += q->spacing();
00251             }
00252             first = first && empty;
00253         }
00254     }
00255     hfwWidth = w;
00256     hfwHeight = h;
00257     hfwMinHeight = mh;
00258 }
00259 
00260 
00365 QBoxLayout::QBoxLayout(Direction dir, QWidget *parent)
00366     : QLayout(*new QBoxLayoutPrivate, 0, parent)
00367 {
00368     Q_D(QBoxLayout);
00369     d->dir = dir;
00370 }
00371 
00372 #ifdef QT3_SUPPORT
00373 
00386 QBoxLayout::QBoxLayout(QWidget *parent, Direction dir,
00387                         int margin, int spacing, const char *name)
00388     : QLayout(*new QBoxLayoutPrivate, 0, parent)
00389 {
00390     Q_D(QBoxLayout);
00391     d->dir = dir;
00392     setMargin(margin);
00393     setObjectName(QString::fromAscii(name));
00394     setSpacing(spacing<0 ? margin : spacing);
00395 }
00396 
00405 QBoxLayout::QBoxLayout(QLayout *parentLayout, Direction dir, int spacing,
00406                         const char *name)
00407     : QLayout(*new QBoxLayoutPrivate, parentLayout, 0)
00408 {
00409     Q_D(QBoxLayout);
00410     d->dir = dir;
00411     setObjectName(QString::fromAscii(name));
00412     setSpacing(spacing);
00413 }
00414 
00423 QBoxLayout::QBoxLayout(Direction dir, int spacing, const char *name)
00424     : QLayout(*new QBoxLayoutPrivate,0, 0)
00425 {
00426     Q_D(QBoxLayout);
00427     d->dir = dir;
00428     setObjectName(QString::fromAscii(name));
00429     setSpacing(spacing);
00430 }
00431 #endif // QT3_SUPPORT
00432 
00433 
00439 QBoxLayout::~QBoxLayout()
00440 {
00441     Q_D(QBoxLayout);
00442     d->deleteAll(); // must do it before QObject deletes children, so can't be in ~QBoxLayoutPrivate
00443 }
00444 
00448 QSize QBoxLayout::sizeHint() const
00449 {
00450     Q_D(const QBoxLayout);
00451     if (d->dirty)
00452         const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
00453     int m = margin();
00454     return d->sizeHint + QSize(2 * m, 2 * m);
00455 }
00456 
00460 QSize QBoxLayout::minimumSize() const
00461 {
00462     Q_D(const QBoxLayout);
00463     if (d->dirty)
00464         const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
00465     int m = margin();
00466     return d->minSize + QSize(2 * m, 2 * m);
00467 }
00468 
00472 QSize QBoxLayout::maximumSize() const
00473 {
00474     Q_D(const QBoxLayout);
00475     if (d->dirty)
00476         const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
00477     int m = margin();
00478     QSize s = (d->maxSize + QSize(2 * m, 2 * m))
00479               .boundedTo(QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX));
00480     if (alignment() & Qt::AlignHorizontal_Mask)
00481         s.setWidth(QLAYOUTSIZE_MAX);
00482     if (alignment() & Qt::AlignVertical_Mask)
00483         s.setHeight(QLAYOUTSIZE_MAX);
00484     return s;
00485 }
00486 
00490 bool QBoxLayout::hasHeightForWidth() const
00491 {
00492     Q_D(const QBoxLayout);
00493     if (d->dirty)
00494         const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
00495     return d->hasHfw;
00496 }
00497 
00501 int QBoxLayout::heightForWidth(int w) const
00502 {
00503     Q_D(const QBoxLayout);
00504     if (!hasHeightForWidth())
00505         return -1;
00506     int m = margin();
00507     w -= 2 * m;
00508     if (w != d->hfwWidth)
00509         const_cast<QBoxLayout*>(this)->d_func()->calcHfw(w);
00510 
00511     return d->hfwHeight + 2 * m;
00512 }
00513 
00517 int QBoxLayout::minimumHeightForWidth(int w) const
00518 {
00519     Q_D(const QBoxLayout);
00520     (void) heightForWidth(w);
00521     return d->hasHfw ? (d->hfwMinHeight + 2 * margin()) : -1;
00522 }
00523 
00527 void QBoxLayout::invalidate()
00528 {
00529     Q_D(QBoxLayout);
00530     d->setDirty();
00531     QLayout::invalidate();
00532 }
00533 
00537 int QBoxLayout::count() const
00538 {
00539     Q_D(const QBoxLayout);
00540     return d->list.count();
00541 }
00542 
00546 QLayoutItem *QBoxLayout::itemAt(int index) const
00547 {
00548     Q_D(const QBoxLayout);
00549     return index >= 0 && index < d->list.count() ? d->list.at(index)->item : 0;
00550 }
00551 
00555 QLayoutItem *QBoxLayout::takeAt(int index)
00556 {
00557     Q_D(QBoxLayout);
00558     if (index < 0 || index >= d->list.count())
00559         return 0;
00560     QBoxLayoutItem *b = d->list.takeAt(index);
00561     QLayoutItem *item = b->item;
00562     b->item = 0;
00563     delete b;
00564 
00565     invalidate();
00566     return item;
00567 }
00568 
00569 
00573 Qt::Orientations QBoxLayout::expandingDirections() const
00574 {
00575     Q_D(const QBoxLayout);
00576     if (d->dirty)
00577         const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
00578     return d->expanding;
00579 }
00580 
00584 void QBoxLayout::setGeometry(const QRect &r)
00585 {
00586     Q_D(QBoxLayout);
00587     if (d->dirty || r != geometry()) {
00588         QRect rect = geometry();
00589         QLayout::setGeometry(r);
00590         if (d->dirty)
00591             d->setupGeom();
00592         QRect cr = alignment() ? alignmentRect(r) : r;
00593         int m = margin();
00594         QRect s(cr.x() + m, cr.y() + m,
00595                  cr.width() - 2 * m, cr.height() - 2 * m);
00596 
00597         QVector<QLayoutStruct> a = d->geomArray;
00598         int pos = horz(d->dir) ? s.x() : s.y();
00599         int space = horz(d->dir) ? s.width() : s.height();
00600         int n = a.count();
00601         if (d->hasHfw && !horz(d->dir)) {
00602             for (int i = 0; i < n; i++) {
00603                 QBoxLayoutItem *box = d->list.at(i);
00604                 if (box->item->hasHeightForWidth())
00605                     a[i].sizeHint = a[i].minimumSize =
00606                                     box->item->heightForWidth(s.width());
00607             }
00608         }
00609 
00610         Direction visualDir = d->dir;
00611         QWidget *parent = parentWidget();
00612         if (parent && parent->isRightToLeft()) {
00613             if (d->dir == LeftToRight)
00614                 visualDir = RightToLeft;
00615             else if (d->dir == RightToLeft)
00616                 visualDir = LeftToRight;
00617         }
00618 
00619         qGeomCalc(a, 0, n, pos, space, spacing());
00620 
00621         bool reverse = (horz(visualDir)
00622                         ? ((r.right() > rect.right()) != (visualDir == RightToLeft))
00623                         : r.bottom() > rect.bottom());
00624         for (int j = 0; j < n; j++) {
00625             int i = reverse ? n-j-1 : j;
00626             QBoxLayoutItem *box = d->list.at(i);
00627 
00628             switch (visualDir) {
00629             case LeftToRight:
00630                 box->item->setGeometry(QRect(a[i].pos, s.y(),
00631                                               a[i].size, s.height()));
00632                 break;
00633             case RightToLeft:
00634                 box->item->setGeometry(QRect(s.left() + s.right()
00635                                               - a[i].pos - a[i].size + 1, s.y(),
00636                                               a[i].size, s.height()));
00637                 break;
00638             case TopToBottom:
00639                 box->item->setGeometry(QRect(s.x(), a[i].pos,
00640                                               s.width(), a[i].size));
00641                 break;
00642             case BottomToTop:
00643                 box->item->setGeometry(QRect(s.x(), s.top() + s.bottom()
00644                                               - a[i].pos - a[i].size + 1,
00645                                               s.width(), a[i].size));
00646             }
00647         }
00648     }
00649 }
00650 
00654 void QBoxLayout::addItem(QLayoutItem *item)
00655 {
00656     Q_D(QBoxLayout);
00657     QBoxLayoutItem *it = new QBoxLayoutItem(item);
00658     d->list.append(it);
00659     invalidate();
00660 }
00661 
00672 void QBoxLayout::insertItem(int index, QLayoutItem *item)
00673 {
00674     Q_D(QBoxLayout);
00675     if (index < 0)                                // append
00676         index = d->list.count();
00677 
00678     QBoxLayoutItem *it = new QBoxLayoutItem(item);
00679     d->list.insert(index, it);
00680     invalidate();
00681 }
00682 
00692 void QBoxLayout::insertSpacing(int index, int size)
00693 {
00694     Q_D(QBoxLayout);
00695     if (index < 0)                                // append
00696         index = d->list.count();
00697 
00698     QLayoutItem *b;
00699     if (horz(d->dir))
00700         b = new QSpacerItem(size, 0, QSizePolicy::Fixed,
00701                              QSizePolicy::Minimum);
00702     else
00703         b = new QSpacerItem(0, size, QSizePolicy::Minimum,
00704                              QSizePolicy::Fixed);
00705 
00706     QBoxLayoutItem *it = new QBoxLayoutItem(b);
00707     it->magic = true;
00708     d->list.insert(index, it);
00709     invalidate();
00710 }
00711 
00719 void QBoxLayout::insertStretch(int index, int stretch)
00720 {
00721     Q_D(QBoxLayout);
00722     if (index < 0)                                // append
00723         index = d->list.count();
00724 
00725     QLayoutItem *b;
00726     if (horz(d->dir))
00727         b = new QSpacerItem(0, 0, QSizePolicy::Expanding,
00728                              QSizePolicy::Minimum);
00729     else
00730         b = new QSpacerItem(0, 0, QSizePolicy::Minimum,
00731                              QSizePolicy::Expanding);
00732 
00733     QBoxLayoutItem *it = new QBoxLayoutItem(b, stretch);
00734     it->magic = true;
00735     d->list.insert(index, it);
00736     invalidate();
00737 }
00738 
00747 void QBoxLayout::insertLayout(int index, QLayout *layout, int stretch)
00748 {
00749     Q_D(QBoxLayout);
00750     addChildLayout(layout);
00751     if (index < 0)                                // append
00752         index = d->list.count();
00753     QBoxLayoutItem *it = new QBoxLayoutItem(layout, stretch);
00754     d->list.insert(index, it);
00755     invalidate();
00756 }
00757 
00778 void QBoxLayout::insertWidget(int index, QWidget *widget, int stretch,
00779                               Qt::Alignment alignment)
00780 {
00781     Q_D(QBoxLayout);
00782     if (!checkWidget(this, widget))
00783          return;
00784     addChildWidget(widget);
00785     if (index < 0)                                // append
00786         index = d->list.count();
00787     QWidgetItem *b = new QWidgetItem(widget);
00788     b->setAlignment(alignment);
00789     QBoxLayoutItem *it = new QBoxLayoutItem(b, stretch);
00790     d->list.insert(index, it);
00791     invalidate();
00792 }
00793 
00801 void QBoxLayout::addSpacing(int size)
00802 {
00803     insertSpacing(-1, size);
00804 }
00805 
00812 void QBoxLayout::addStretch(int stretch)
00813 {
00814     insertStretch(-1, stretch);
00815 }
00816 
00837 void QBoxLayout::addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
00838 {
00839     insertWidget(-1, widget, stretch, alignment);
00840 }
00841 
00848 void QBoxLayout::addLayout(QLayout *layout, int stretch)
00849 {
00850     insertLayout(-1, layout, stretch);
00851 }
00852 
00860 void QBoxLayout::addStrut(int size)
00861 {
00862     Q_D(QBoxLayout);
00863     QLayoutItem *b;
00864     if (horz(d->dir))
00865         b = new QSpacerItem(0, size, QSizePolicy::Fixed, QSizePolicy::Minimum);
00866     else
00867         b = new QSpacerItem(size, 0, QSizePolicy::Minimum, QSizePolicy::Fixed);
00868 
00869     QBoxLayoutItem *it = new QBoxLayoutItem(b);
00870     it->magic = true;
00871     d->list.append(it);
00872     invalidate();
00873 }
00874 
00888 bool QBoxLayout::setStretchFactor(QWidget *widget, int stretch)
00889 {
00890     Q_D(QBoxLayout);
00891     for (int i = 0; i < d->list.size(); ++i) {
00892         QBoxLayoutItem *box = d->list.at(i);
00893         if (box->item->widget() == widget) {
00894             box->stretch = stretch;
00895             invalidate();
00896             return true;
00897         }
00898     }
00899     return false;
00900 }
00901 
00909 bool QBoxLayout::setStretchFactor(QLayout *layout, int stretch)
00910 {
00911     Q_D(QBoxLayout);
00912     for (int i = 0; i < d->list.size(); ++i) {
00913         QBoxLayoutItem *box = d->list.at(i);
00914         if (box->item->layout() == layout) {
00915             box->stretch = stretch;
00916             invalidate();
00917             return true;
00918         }
00919     }
00920     return false;
00921 }
00922 
00926 void QBoxLayout::setDirection(Direction direction)
00927 {
00928     Q_D(QBoxLayout);
00929     if (d->dir == direction)
00930         return;
00931     if (horz(d->dir) != horz(direction)) {
00932         //swap around the spacers (the "magic" bits)
00933         //#### a bit yucky, knows too much.
00934         //#### probably best to add access functions to spacerItem
00935         //#### or even a QSpacerItem::flip()
00936         for (int i = 0; i < d->list.size(); ++i) {
00937             QBoxLayoutItem *box = d->list.at(i);
00938             if (box->magic) {
00939                 QSpacerItem *sp = box->item->spacerItem();
00940                 if (sp) {
00941                     if (sp->expandingDirections() == Qt::Orientations(0) /*No Direction*/) {
00942                         //spacing or strut
00943                         QSize s = sp->sizeHint();
00944                         sp->changeSize(s.height(), s.width(),
00945                             horz(direction) ? QSizePolicy::Fixed:QSizePolicy::Minimum,
00946                             horz(direction) ? QSizePolicy::Minimum:QSizePolicy::Fixed);
00947 
00948                     } else {
00949                         //stretch
00950                         if (horz(direction))
00951                             sp->changeSize(0, 0, QSizePolicy::Expanding,
00952                                             QSizePolicy::Minimum);
00953                         else
00954                             sp->changeSize(0, 0, QSizePolicy::Minimum,
00955                                             QSizePolicy::Expanding);
00956                     }
00957                 }
00958             }
00959         }
00960     }
00961     d->dir = direction;
00962     invalidate();
00963 }
00964 
00974 QBoxLayout::Direction QBoxLayout::direction() const
00975 {
00976     Q_D(const QBoxLayout);
00977     return d->dir;
00978 }
00979 
01018 QHBoxLayout::QHBoxLayout(QWidget *parent)
01019     : QBoxLayout(LeftToRight, parent)
01020 {
01021 }
01022 
01027 QHBoxLayout::QHBoxLayout()
01028     : QBoxLayout(LeftToRight)
01029 {
01030 }
01031 
01032 
01033 
01034 #ifdef QT3_SUPPORT
01035 
01044 QHBoxLayout::QHBoxLayout(QWidget *parent, int margin,
01045                           int spacing, const char *name)
01046     : QBoxLayout(LeftToRight, parent)
01047 {
01048        setMargin(margin);
01049        setSpacing(spacing<0 ? margin : spacing);
01050        setObjectName(QString::fromAscii(name));
01051 }
01052 
01061 QHBoxLayout::QHBoxLayout(QLayout *parentLayout, int spacing,
01062                           const char *name)
01063     : QBoxLayout(LeftToRight)
01064 {
01065     setSpacing(spacing);
01066     setObjectName(QString::fromAscii(name));
01067     if (parentLayout) {
01068         setParent(parentLayout);
01069         parentLayout->addItem(this);
01070     }
01071 }
01072 
01081 QHBoxLayout::QHBoxLayout(int spacing, const char *name)
01082     : QBoxLayout(LeftToRight)
01083 {
01084     setSpacing(spacing);
01085     setObjectName(QString::fromAscii(name));
01086 }
01087 #endif
01088 
01089 
01095 QHBoxLayout::~QHBoxLayout()
01096 {
01097 }
01098 
01137 QVBoxLayout::QVBoxLayout(QWidget *parent)
01138     : QBoxLayout(TopToBottom, parent)
01139 {
01140 }
01141 
01147 QVBoxLayout::QVBoxLayout()
01148     : QBoxLayout(TopToBottom)
01149 {
01150 }
01151 
01152 #ifdef QT3_SUPPORT
01153 
01162 QVBoxLayout::QVBoxLayout(QWidget *parent, int margin, int spacing,
01163                           const char *name)
01164     : QBoxLayout(TopToBottom, parent)
01165 {
01166     setMargin(margin);
01167     setSpacing(spacing<0 ? margin : spacing);
01168     setObjectName(QString::fromAscii(name));
01169 }
01170 
01179 QVBoxLayout::QVBoxLayout(QLayout *parentLayout, int spacing,
01180                           const char *name)
01181     : QBoxLayout(TopToBottom)
01182 {
01183     setSpacing(spacing);
01184     setObjectName(QString::fromAscii(name));
01185     if (parentLayout) {
01186         setParent(parentLayout);
01187         parentLayout->addItem(this);
01188     }
01189 }
01190 
01199 QVBoxLayout::QVBoxLayout(int spacing, const char *name)
01200     : QBoxLayout(TopToBottom)
01201 {
01202     setSpacing(spacing);
01203     setObjectName(QString::fromAscii(name));
01204 }
01205 
01206 
01207 #endif
01208 
01214 QVBoxLayout::~QVBoxLayout()
01215 {
01216 }
01217 

Generated on Thu Mar 15 11:55:04 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1