QSplitter Class Reference

#include <qsplitter.h>

Inheritance diagram for QSplitter:

Inheritance graph
[legend]
Collaboration diagram for QSplitter:

Collaboration graph
[legend]
List of all members.

Detailed Description

The QSplitter class implements a splitter widget.

A splitter lets the user control the size of child widgets by dragging the boundary between the children. Any number of widgets may be controlled by a single splitter. The typical use of a QSplitter is to create several widgets and add them using insertWidget() or addWidget().

The following example will show a QListView, QTreeView, and QTextEdit side by side, with two splitter handles:

snippets/splitter/splitter.cpp QSplitter splitter->addWidget(textedit);

If a widget is already inside a QSplitter when insertWidget() or addWidget() is called, it will move to the new position. This can be used to reorder widgets in the splitter later. You can use indexOf(), widget(), and count() to get access to the widgets inside the splitter.

A default QSplitter lays out its children horizontally (side by side); you can use setOrientation(Qt::Vertical) to lay its children out vertically.

By default, all widgets can be as large or as small as the user wishes, between the minimumSizeHint() (or minimumSize()) and maximumSize() of the widgets.

QSplitter resizes its children dynamically by default. If you would rather have QSplitter resize the children only at the end of a resize operation, call setOpaqueResize(false).

The initial distribution of size between the widgets is determined by the initial size of each widget. You can also use setSizes() to set the sizes of all the widgets. The function sizes() returns the sizes set by the user. Alternatively, you can save and restore the sizes of the widgets from a QByteArray using saveState() and restoreState() respectively.

When you hide() a child its space will be distributed among the other children. It will be reinstated when you show() it again.

See also:
QSplitterHandle, QHBoxLayout, QVBoxLayout, QTabWidget

Definition at line 42 of file qsplitter.h.

Signals

void splitterMoved (int pos, int index)

Public Member Functions

 QSplitter (QWidget *parent=0)
 QSplitter (Qt::Orientation, QWidget *parent=0)
 ~QSplitter ()
void addWidget (QWidget *widget)
void insertWidget (int index, QWidget *widget)
void setOrientation (Qt::Orientation)
Qt::Orientation orientation () const
void setChildrenCollapsible (bool)
bool childrenCollapsible () const
void setCollapsible (int index, bool)
bool isCollapsible (int index) const
void setOpaqueResize (bool opaque=true)
bool opaqueResize () const
void refresh ()
QSize sizeHint () const
QSize minimumSizeHint () const
QList< int > sizes () const
void setSizes (const QList< int > &list)
QByteArray saveState () const
bool restoreState (const QByteArray &state)
int handleWidth () const
void setHandleWidth (int)
int indexOf (QWidget *w) const
QWidgetwidget (int index) const
int count () const
void getRange (int index, int *, int *) const
QSplitterHandlehandle (int index) const
void setStretchFactor (int index, int stretch)

Protected Member Functions

virtual QSplitterHandlecreateHandle ()
void childEvent (QChildEvent *)
bool event (QEvent *)
void resizeEvent (QResizeEvent *)
void changeEvent (QEvent *)
void moveSplitter (int pos, int index)
void setRubberBand (int position)
int closestLegalPosition (int, int)

Friends

class QSplitterHandle

Related Functions

(Note that these are not member functions.)

QTextStreamoperator<< (QTextStream &ts, const QSplitter &splitter)
QTextStreamoperator>> (QTextStream &ts, QSplitter &splitter)


Constructor & Destructor Documentation

QSplitter::QSplitter ( QWidget parent = 0  )  [explicit]

Constructs a horizontal splitter with the parent arguments is passed on to the QFrame constructor.

See also:
setOrientation()

Definition at line 913 of file qsplitter.cpp.

References d, and Qt::Horizontal.

00914     : QFrame(*new QSplitterPrivate, parent)
00915 {
00916     Q_D(QSplitter);
00917     d->orient = Qt::Horizontal;
00918     d->init();
00919 }

QSplitter::QSplitter ( Qt::Orientation  orientation,
QWidget parent = 0 
) [explicit]

Constructs a splitter with the given orientation and parent.

See also:
setOrientation()

Definition at line 927 of file qsplitter.cpp.

References d.

00928     : QFrame(*new QSplitterPrivate, parent)
00929 {
00930     Q_D(QSplitter);
00931     d->orient = orientation;
00932     d->init();
00933 }

QSplitter::~QSplitter (  ) 

Destroys the splitter. All children are deleted.

Definition at line 940 of file qsplitter.cpp.

References d.

00941 {
00942     Q_D(QSplitter);
00943     while (!d->list.isEmpty())
00944         delete d->list.takeFirst();
00945 }


Member Function Documentation

void QSplitter::addWidget ( QWidget widget  ) 

Adds the given widget to the splitter's layout after all the other items.

If widget is already in the splitter, it will be moved to the new position.

See also:
insertWidget() widget() indexOf()

Definition at line 1073 of file qsplitter.cpp.

References d, insertWidget(), and widget().

Referenced by qdesigner_internal::ActionEditor::ActionEditor(), childEvent(), qdesigner_internal::HorizontalLayout::doLayout(), qdesigner_internal::VerticalLayout::doLayout(), Main::Main(), main(), MainWindow::MainWindow(), and MainWindow::setupViews().

01074 {
01075     Q_D(QSplitter);
01076     insertWidget(d->list.count(), widget);
01077 }

Here is the call graph for this function:

void QSplitter::insertWidget ( int  index,
QWidget widget 
)

Inserts the widget specified into the splitter's layout at the given index.

If widget is already in the splitter, it will be moved to the new position.

if index is an invalid index, then the widget will be inserted at the end.

See also:
addWidget() indexOf() widget()

Definition at line 1089 of file qsplitter.cpp.

References b, d, QWidget::isHidden(), QWidget::isVisible(), QWidget::parentWidget(), QWidget::setParent(), QWidget::show(), QWidget::testAttribute(), Qt::WA_WState_ExplicitShowHide, and widget().

Referenced by addWidget().

01090 {
01091     Q_D(QSplitter);
01092     QBoolBlocker b(d->blockChildAdd);
01093     bool needShow = isVisible() &&
01094                     !(widget->isHidden() && widget->testAttribute(Qt::WA_WState_ExplicitShowHide));
01095     if (widget->parentWidget() != this)
01096         widget->setParent(this);
01097     if (needShow)
01098         widget->show();
01099     d->insertWidget(index, widget);
01100     d->recalc(isVisible());
01101 }

Here is the call graph for this function:

void QSplitter::setOrientation ( Qt::Orientation   ) 

Definition at line 968 of file qsplitter.cpp.

References d, i, QWidget::isVisible(), s, QWidget::setAttribute(), QWidget::setSizePolicy(), QWidget::sizePolicy(), QWidget::testAttribute(), QSizePolicy::transpose(), and Qt::WA_WState_OwnSizePolicy.

Referenced by MainWindow::MainWindow(), and restoreState().

00969 {
00970     Q_D(QSplitter);
00971     if (d->orient == orientation)
00972         return;
00973 
00974     if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
00975         QSizePolicy sp = sizePolicy();
00976         sp.transpose();
00977         setSizePolicy(sp);
00978         setAttribute(Qt::WA_WState_OwnSizePolicy, false);
00979     }
00980 
00981     d->orient = orientation;
00982 
00983     for (int i = 0; i < d->list.size(); ++i) {
00984         QSplitterLayoutStruct *s = d->list.at(i);
00985         s->handle->setOrientation(orientation);
00986     }
00987     d->recalc(isVisible());
00988 }

Here is the call graph for this function:

Qt::Orientation QSplitter::orientation (  )  const

Definition at line 990 of file qsplitter.cpp.

References d.

Referenced by minimumSizeHint(), saveState(), and sizeHint().

00991 {
00992     Q_D(const QSplitter);
00993     return d->orient;
00994 }

void QSplitter::setChildrenCollapsible ( bool   ) 

Definition at line 1007 of file qsplitter.cpp.

References d.

Referenced by restoreState().

01008 {
01009     Q_D(QSplitter);
01010     d->childrenCollapsible = collapse;
01011 }

bool QSplitter::childrenCollapsible (  )  const

Definition at line 1013 of file qsplitter.cpp.

References d.

Referenced by saveState().

01014 {
01015     Q_D(const QSplitter);
01016     return d->childrenCollapsible;
01017 }

void QSplitter::setCollapsible ( int  index,
bool  collapse 
)

Sets whether the child widget at index index is collapsible to collapse.

By default, children are collapsible, meaning that the user can resize them down to size 0, even if they have a non-zero minimumSize() or minimumSizeHint(). This behavior can be changed on a per-widget basis by calling this function, or globally for all the widgets in the splitter by setting the childrenCollapsible property.

See also:
childrenCollapsible

Definition at line 1032 of file qsplitter.cpp.

References d, and qWarning().

01033 {
01034     Q_D(QSplitter);
01035 
01036     if (index < 0 || index >= d->list.size()) {
01037         qWarning("QSplitter::setCollapsible: Index %d out of range", index);
01038         return;
01039     }
01040     d->list.at(index)->collapsible = collapse ? 1 : 0;
01041 }

Here is the call graph for this function:

bool QSplitter::isCollapsible ( int  index  )  const

Returns true if the widget at index is collapsible, otherwise returns false

Definition at line 1046 of file qsplitter.cpp.

References d, and qWarning().

01047 {
01048     Q_D(const QSplitter);
01049     if (index < 0 || index >= d->list.size()) {
01050         qWarning("QSplitter::isCollapsible: Index %d out of range", index);
01051         return false;
01052     }
01053     return d->list.at(index)->collapsible;
01054 }

Here is the call graph for this function:

void QSplitter::setOpaqueResize ( bool  opaque = true  ) 

Definition at line 1396 of file qsplitter.cpp.

References d.

Referenced by restoreState().

01397 {
01398     Q_D(QSplitter);
01399     d->opaque = on;
01400 }

bool QSplitter::opaqueResize (  )  const

Definition at line 1389 of file qsplitter.cpp.

References d.

Referenced by saveState().

01390 {
01391     Q_D(const QSplitter);
01392     return d->opaque;
01393 }

void QSplitter::refresh (  ) 

Updates the splitter's state. You should not need to call this function.

Definition at line 951 of file qsplitter.cpp.

References d.

00952 {
00953     Q_D(QSplitter);
00954     d->recalc(true);
00955 }

QSize QSplitter::sizeHint (  )  const [virtual]

Reimplemented from QFrame.

Definition at line 1472 of file qsplitter.cpp.

References QList< T >::at(), QObject::children(), d, QWidget::ensurePolished(), Qt::Horizontal, i, l, orientation(), qMax(), qobject_cast< QWidget * >(), s, QList< T >::size(), t, and w.

01473 {
01474     Q_D(const QSplitter);
01475     ensurePolished();
01476     int l = 0;
01477     int t = 0;
01478     QObjectList childList = children();
01479     for (int i = 0; i < childList.size(); ++i) {
01480         if (QWidget *w = qobject_cast<QWidget *>(childList.at(i))) {
01481             if (w->isHidden())
01482                 continue;
01483             QSize s = w->sizeHint();
01484             if (s.isValid()) {
01485                 l += d->pick(s);
01486                 t = qMax(t, d->trans(s));
01487             }
01488         }
01489     }
01490     return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);
01491 }

Here is the call graph for this function:

QSize QSplitter::minimumSizeHint (  )  const [virtual]

Reimplemented from QWidget.

Definition at line 1498 of file qsplitter.cpp.

References QList< T >::at(), QObject::children(), d, QWidget::ensurePolished(), Qt::Horizontal, i, l, orientation(), qMax(), qobject_cast< QWidget * >(), qSmartMinSize(), s, QList< T >::size(), t, and w.

01499 {
01500     Q_D(const QSplitter);
01501     ensurePolished();
01502     int l = 0;
01503     int t = 0;
01504     QObjectList childList = children();
01505     for (int i = 0; i < childList.size(); ++i) {
01506         if (QWidget *w = qobject_cast<QWidget *>(childList.at(i))) {
01507             if (w->isHidden())
01508                 continue;
01509             QSize s = qSmartMinSize(w);
01510             if (s.isValid()) {
01511                 l += d->pick(s);
01512                 t = qMax(t, d->trans(s));
01513             }
01514         }
01515     }
01516     return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);
01517 }

Here is the call graph for this function:

QList< int > QSplitter::sizes (  )  const

Returns a list of the size parameters of all the widgets in this splitter.

If the splitter's orientation is horizontal, the list is a list of widget widths; if the orientation is vertical, the list is a list of widget heights.

Giving the values to another splitter's setSizes() function will produce a splitter with the same layout as this one.

The easiest way to iterate over the list is to use the Java-style iterators.

snippets/splitter/splitter.cpp QListIterator<int> processSize(it.next());

See also:
setSizes()

Definition at line 1540 of file qsplitter.cpp.

References QList< T >::append(), d, QWidget::ensurePolished(), i, and s.

Referenced by saveState().

01541 {
01542     Q_D(const QSplitter);
01543     ensurePolished();
01544 
01545     QList<int> list;
01546     for (int i = 0; i < d->list.size(); ++i) {
01547         QSplitterLayoutStruct *s = d->list.at(i);
01548         list.append(d->pick(s->rect.size()));
01549     }
01550     return list;
01551 }

Here is the call graph for this function:

void QSplitter::setSizes ( const QList< int > &  list  ) 

Sets the size parameters to the values given in the list. If the splitter is horizontal, the values set the widths of each widget going from left to right. If the splitter is vertical, the values set the heights of each widget going from top to bottom. Extra values in the list are ignored.

If list contains too few values, the result is undefined but the program will still be well-behaved.

The values in list should be the height or width (depending on orientation()) that the widgets should be resized to.

See also:
sizes()

Definition at line 1569 of file qsplitter.cpp.

References d, i, j, qMax(), qSmartMinSize(), s, and QList< T >::value().

Referenced by restoreState().

01570 {
01571     Q_D(QSplitter);
01572     int j = 0;
01573 
01574     for (int i = 0; i < d->list.size(); ++i) {
01575         QSplitterLayoutStruct *s = d->list.at(i);
01576 
01577         s->collapsed = false;
01578         s->sizer = qMax(list.value(j++), 0);
01579         int smartMinSize = d->pick(qSmartMinSize(s->widget));
01580 
01581         // Make sure that we reset the collapsed state.
01582         if (s->sizer == 0) {
01583             if (d->collapsible(s) && smartMinSize > 0) {
01584                 s->collapsed = true;
01585             } else {
01586                 s->sizer = smartMinSize;
01587             }
01588         } else {
01589             if (s->sizer < smartMinSize)
01590                 s->sizer = smartMinSize;
01591         }
01592     }
01593     d->doResize();
01594 }

Here is the call graph for this function:

QByteArray QSplitter::saveState (  )  const

Saves the state of the splitter's layout.

Typically this is used in conjunction with QSettings to remember the size for a future session. A version number is stored as part of the data. Here is an example:

snippets/splitter/splitter.cpp SAVE QSettings saveState()

See also:
restoreState()

Definition at line 1645 of file qsplitter.cpp.

References childrenCollapsible(), data, handleWidth(), opaqueResize(), orientation(), sizes(), QTest::stream, version, and QIODevice::WriteOnly.

Referenced by operator<<().

01646 {
01647     int version = 0;
01648     QByteArray data;
01649     QDataStream stream(&data, QIODevice::WriteOnly);
01650 
01651     stream << qint32(SplitterMagic);
01652     stream << qint32(version);
01653     stream << sizes();
01654     stream << childrenCollapsible();
01655     stream << qint32(handleWidth());
01656     stream << opaqueResize();
01657     stream << qint32(orientation());
01658     return data;
01659 }

Here is the call graph for this function:

bool QSplitter::restoreState ( const QByteArray state  ) 

Restores the splitter's layout to the state specified. Returns true if the state is restored; otherwise returns false.

Typically this is used in conjunction with QSettings to restore the size from a past session. Here is an example:

Restore the splitters's state:

snippets/splitter/splitter.cpp RESTORE QSettings restoreState(

A failure to restore the splitter's layout may result from either invalid or out-of-date data in the supplied byte array.

See also:
saveState()

Definition at line 1680 of file qsplitter.cpp.

References b, d, i, marker, QIODevice::ReadOnly, setChildrenCollapsible(), setHandleWidth(), setOpaqueResize(), setOrientation(), setSizes(), QTest::stream, and version.

Referenced by operator>>().

01681 {
01682     Q_D(QSplitter);
01683     int version = 0;
01684     QByteArray sd = state;
01685     QDataStream stream(&sd, QIODevice::ReadOnly);
01686     QList<int> list;
01687     bool b;
01688     qint32 i;
01689     qint32 marker;
01690     qint32 v;
01691 
01692     stream >> marker;
01693     stream >> v;
01694     if (marker != SplitterMagic || v != version)
01695         return false;
01696 
01697     stream >> list;
01698     setSizes(list);
01699 
01700     stream >> b;
01701     setChildrenCollapsible(b);
01702 
01703     stream >> i;
01704     setHandleWidth(i);
01705 
01706     stream >> b;
01707     setOpaqueResize(b);
01708 
01709     stream >> i;
01710     setOrientation(Qt::Orientation(i));
01711     d->doResize();
01712 
01713     return true;
01714 }

Here is the call graph for this function:

int QSplitter::handleWidth (  )  const

Definition at line 1601 of file qsplitter.cpp.

References d, QStyle::pixelMetric(), QStyle::PM_SplitterWidth, and QWidget::style().

Referenced by saveState(), and setRubberBand().

01602 {
01603     Q_D(const QSplitter);
01604     if (d->handleWidth > 0) {
01605         return d->handleWidth;
01606     } else {
01607         return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this);
01608     }
01609 }

Here is the call graph for this function:

void QSplitter::setHandleWidth ( int   ) 

Definition at line 1611 of file qsplitter.cpp.

References d.

Referenced by restoreState().

01612 {
01613     Q_D(QSplitter);
01614     d->handleWidth = width;
01615     d->updateHandles();
01616 }

int QSplitter::indexOf ( QWidget widget  )  const

Returns the index in the splitter's layout of the specified widget. This also works for handles.

Handles are numbered from 0. There are as many handles as there are child widgets, but the handle at position 0 is always hidden.

See also:
count(), widget()

Definition at line 1115 of file qsplitter.cpp.

References d, i, s, and w.

01116 {
01117     Q_D(const QSplitter);
01118     for (int i = 0; i < d->list.size(); ++i) {
01119         QSplitterLayoutStruct *s = d->list.at(i);
01120         if (s->widget == w || s->handle == w)
01121             return i;
01122     }
01123     return -1;
01124 }

QWidget * QSplitter::widget ( int  index  )  const

Returns the widget at the given index in the splitter's layout.

See also:
count(), handle(), indexOf(), insertWidget()

Definition at line 1163 of file qsplitter.cpp.

References d.

Referenced by addWidget(), insertWidget(), and setStretchFactor().

01164 {
01165     Q_D(const QSplitter);
01166     if (index < 0 || index >= d->list.size())
01167         return 0;
01168     return d->list.at(index)->widget;
01169 }

int QSplitter::count (  )  const

Returns the number of widgets contained in the splitter's layout.

See also:
widget(), handle()

Definition at line 1176 of file qsplitter.cpp.

References d.

Referenced by moveSplitter().

01177 {
01178     Q_D(const QSplitter);
01179     return d->list.count();
01180 }

void QSplitter::getRange ( int  index,
int *  min,
int *  max 
) const

Returns the valid range of the splitter with index index in {min} and *{max} if min and max are not 0.

Definition at line 1357 of file qsplitter.cpp.

References d.

01358 {
01359     Q_D(const QSplitter);
01360     d->getRange(index, min, 0, 0, max);
01361 }

QSplitterHandle * QSplitter::handle ( int  index  )  const

Returns the handle to the left (or above) for the item in the splitter's layout at the given index. The handle at index 0 is always hidden.

For right-to-left languages such as Arabic and Hebrew, the layout of horizontal splitters is reversed. The handle will be to the right of the widget at index.

See also:
count(), widget(), indexOf(), createHandle(), setHandleWidth()

Definition at line 1150 of file qsplitter.cpp.

References d.

01151 {
01152     Q_D(const QSplitter);
01153     if (index < 0 || index >= d->list.size())
01154         return 0;
01155     return d->list.at(index)->handle;
01156 }

void QSplitter::setStretchFactor ( int  index,
int  stretch 
)

Updates the size policy of the widget at position index to have a stretch factor of stretch.

This function is provided for convenience. It is equivalent to

        QWidget *widget = splitter->widget(index);
        QSizePolicy policy = widget->sizePolicy();
        policy.setHorizontalStretch(stretch);
        policy.setVerticalStretch(stretch);
        widget->setSizePolicy(policy);

See also:
setSizes(), widget()

Definition at line 1732 of file qsplitter.cpp.

References d, QSizePolicy::setHorizontalStretch(), QWidget::setSizePolicy(), QSizePolicy::setVerticalStretch(), QWidget::sizePolicy(), and widget().

Referenced by MainWindow::setupViews().

01733 {
01734     Q_D(QSplitter);
01735     if (index <= -1 || index >= d->list.count())
01736         return;
01737 
01738     QWidget *widget = d->list.at(index)->widget;
01739     QSizePolicy sp = widget->sizePolicy();
01740     sp.setHorizontalStretch(stretch);
01741     sp.setVerticalStretch(stretch);
01742     widget->setSizePolicy(sp);
01743 }

Here is the call graph for this function:

QSplitter::splitterMoved ( int  pos,
int  index 
) [signal]

This signal is emitted when the splitter handle at a particular index has been moved to position pos.

For right-to-left languages such as Arabic and Hebrew, the layout of horizontal splitters is reversed. pos is then the distance from the right edge of the widget.

See also:
moveSplitter()

Referenced by moveSplitter().

QSplitterHandle * QSplitter::createHandle (  )  [protected, virtual]

Returns a new splitter handle as a child widget of this splitter. This function can be reimplemented in subclasses to provide support for custom handles.

See also:
handle(), indexOf()

Definition at line 1133 of file qsplitter.cpp.

References d, and QSplitterHandle.

01134 {
01135     Q_D(QSplitter);
01136     return new QSplitterHandle(d->orient, this);
01137 }

void QSplitter::childEvent ( QChildEvent c  )  [protected, virtual]

Tells the splitter that the child widget described by c has been inserted or removed.

This method is also used to handle the situation where a widget is created with the splitter as a parent but not explicitly added with insertWidget() or addWidget(). This is for compatibility and not the recommended way of putting widgets into a splitter in new code. Please use insertWidget() or addWidget() in new code.

See also:
addWidget() insertWidget()

Reimplemented from QObject.

Definition at line 1197 of file qsplitter.cpp.

References addWidget(), c, QEvent::ChildRemoved, d, i, QWidget::isVisible(), s, and w.

01198 {
01199     Q_D(QSplitter);
01200     if (!c->child()->isWidgetType())
01201         return;
01202     QWidget *w = static_cast<QWidget*>(c->child());
01203 
01204     if (c->added() && !d->blockChildAdd && !w->isWindow() && !d->findWidget(w)) {
01205         addWidget(w);
01206     } else  if (c->type() == QEvent::ChildRemoved) {
01207         for (int i = 0; i < d->list.size(); ++i) {
01208             QSplitterLayoutStruct *s = d->list.at(i);
01209             if (s->widget == w) {
01210                 d->list.removeAt(i);
01211                 delete s;
01212                 d->recalc(isVisible());
01213                 return;
01214             }
01215         }
01216     }
01217 }

Here is the call graph for this function:

bool QSplitter::event ( QEvent e  )  [protected, virtual]

Reimplemented from QFrame.

Definition at line 1254 of file qsplitter.cpp.

References d, QWidget::event(), QEvent::Hide, QEvent::HideToParent, QWidget::isVisible(), QEvent::LayoutRequest, QEvent::Show, QEvent::ShowToParent, and QEvent::type().

01255 {
01256     Q_D(QSplitter);
01257     switch (e->type()) {
01258     case QEvent::Hide:
01259         // Reset firstShow to false here since things can be done to the splitter in between
01260         if (!d->firstShow)
01261             d->firstShow = true;
01262         break;
01263     case QEvent::Show:
01264         if (!d->firstShow)
01265             break;
01266         d->firstShow = false;
01267         // fall through
01268     case QEvent::HideToParent:
01269     case QEvent::ShowToParent:
01270     case QEvent::LayoutRequest:
01271 #ifdef QT3_SUPPORT
01272     case QEvent::LayoutHint:
01273 #endif
01274         d->recalc(isVisible());
01275         break;
01276     default:
01277         ;
01278     }
01279     return QWidget::event(e);
01280 }

Here is the call graph for this function:

void QSplitter::resizeEvent ( QResizeEvent  )  [protected, virtual]

Reimplemented from QWidget.

Definition at line 1059 of file qsplitter.cpp.

References d.

01060 {
01061     Q_D(QSplitter);
01062     d->doResize();
01063 }

void QSplitter::changeEvent ( QEvent ev  )  [protected, virtual]

Reimplemented from QFrame.

Definition at line 1621 of file qsplitter.cpp.

References QFrame::changeEvent(), d, QEvent::StyleChange, and QEvent::type().

01622 {
01623     Q_D(QSplitter);
01624     if(ev->type() == QEvent::StyleChange)
01625         d->updateHandles();
01626     QFrame::changeEvent(ev);
01627 }

Here is the call graph for this function:

void QSplitter::moveSplitter ( int  pos,
int  index 
) [protected]

Moves the left or top edge of the splitter handle at index as close as possible to position pos, which is the distance from the left or top edge of the widget.

For right-to-left languages such as Arabic and Hebrew, the layout of horizontal splitters is reversed. pos is then the distance from the right edge of the widget.

See also:
splitterMoved(), closestLegalPosition(), getRange()

Definition at line 1306 of file qsplitter.cpp.

References count(), d, emit, qDebug(), s, splitterMoved(), and ws().

01307 {
01308     Q_D(QSplitter);
01309     QSplitterLayoutStruct *s = d->list.at(index);
01310     int farMin;
01311     int min;
01312     int max;
01313     int farMax;
01314 
01315 #ifdef QSPLITTER_DEBUG
01316     int debugp = pos;
01317 #endif
01318 
01319     pos = d->adjustPos(pos, index, &farMin, &min, &max, &farMax);
01320     int oldP = d->pick(s->rect.topLeft());
01321 #ifdef QSPLITTER_DEBUG
01322     qDebug() << "QSplitter::moveSplitter" << debugp << index << "adjusted" << pos << "oldP" << oldP;
01323 #endif
01324 
01325     QVarLengthArray<int, 32> poss(d->list.count());
01326     QVarLengthArray<int, 32> ws(d->list.count());
01327     bool upLeft;
01328 
01329     d->doMove(false, pos, index, +1, (d->collapsible(s) && (pos > max)), poss.data(), ws.data());
01330     d->doMove(true, pos, index - 1, +1, (d->collapsible(index - 1) && (pos < min)), poss.data(), ws.data());
01331     upLeft = (pos < oldP);
01332 
01333     int wid, delta, count = d->list.count();
01334     if (upLeft) {
01335         wid = 0;
01336         delta = 1;
01337     } else {
01338         wid = count - 1;
01339         delta = -1;
01340     }
01341     for (; wid >= 0 && wid < count; wid += delta) {
01342         QSplitterLayoutStruct *sls = d->list.at( wid );
01343         if (!sls->widget->isHidden())
01344             d->setGeo(sls, poss[wid], ws[wid], true);
01345     }
01346     d->storeSizes();
01347 
01348     emit splitterMoved(pos, index);
01349 }

Here is the call graph for this function:

void QSplitter::setRubberBand ( int  pos  )  [protected]

Displays a rubber band at position pos. If pos is negative, the rubber band is removed.

Definition at line 1225 of file qsplitter.cpp.

References QWidget::contentsRect(), d, handleWidth(), QRect::height(), Qt::Horizontal, QRubberBand::Line, QRect::width(), QRect::x(), and QRect::y().

01226 {
01227     Q_D(QSplitter);
01228     if (pos < 0) {
01229         if (d->rubberBand)
01230             d->rubberBand->hide();
01231         return;
01232     }
01233     QRect r = contentsRect();
01234     const int rBord = 3; // customizable?
01235     int hw = handleWidth();
01236     if (!d->rubberBand) {
01237         QBoolBlocker block(d->blockChildAdd);
01238         d->rubberBand = new QRubberBand(QRubberBand::Line, this);
01239     }
01240     if (d->orient == Qt::Horizontal)
01241         d->rubberBand->setGeometry(QRect(QPoint(pos + hw / 2 - rBord, r.y()),
01242                                          QSize(2 * rBord, r.height())));
01243     else
01244         d->rubberBand->setGeometry(QRect(QPoint(r.x(), pos + hw / 2 - rBord),
01245                                    QSize(r.width(), 2 * rBord)));
01246     if (!d->rubberBand->isVisible())
01247         d->rubberBand->show();
01248 }

Here is the call graph for this function:

int QSplitter::closestLegalPosition ( int  pos,
int  index 
) [protected]

Returns the closest legal position to pos of the widget with index index.

For right-to-left languages such as Arabic and Hebrew, the layout of horizontal splitters is reversed. Positions are then measured from the right edge of the widget.

See also:
getRange()

Definition at line 1375 of file qsplitter.cpp.

References d, i, n, u, and QWidget::x().

01376 {
01377     Q_D(QSplitter);
01378     int x, i, n, u;
01379     return d->adjustPos(pos, index, &u, &n, &i, &x);
01380 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class QSplitterHandle [friend]

Definition at line 127 of file qsplitter.h.

Referenced by createHandle().

QTextStream & operator<< ( QTextStream ts,
const QSplitter splitter 
) [related]

Use ts << {splitter}.saveState() instead.

Definition at line 1755 of file qsplitter.cpp.

References QTextStream::endl(), and saveState().

01756 {
01757     ts << splitter.saveState() << endl;
01758     return ts;
01759 }

Here is the call graph for this function:

QTextStream & operator>> ( QTextStream ts,
QSplitter splitter 
) [related]

Use ts >> {splitter}.restoreState() instead.

Definition at line 1768 of file qsplitter.cpp.

References QTextStream::readLine(), QString::replace(), restoreState(), QString::simplified(), QString::toAscii(), and QString::toUpper().

01769 {
01770     QString line = ts.readLine();
01771     line = line.simplified();
01772     line.replace(QLatin1Char(' '), QString());
01773     line = line.toUpper();
01774 
01775     splitter.restoreState(line.toAscii());
01776     return ts;
01777 }

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 18:58:47 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1