Qt Toolkit - QSplitter Class

# QSplitter Class Reference

QSplitter implements a splitter widget. More...

`#include <qsplitter.h>`

Inherits QFrame.

List of all member functions.

## Public Members

- enum ResizeMode { Stretch, KeepSize }
- QSplitter ( QWidget * parent=0, const char * name=0 )
- QSplitter ( Orientation, QWidget * parent=0, const char * name=0 )
- void setOrientation ( Orientation )
- Orientation orientation () const
- void setResizeMode ( QWidget * w, ResizeMode )
- virtual bool event ( QEvent * )
- void setOpaqueResize ( bool = TRUE )
- bool opaqueResize () const
- void moveToFirst ( QWidget * )
- void moveToLast ( QWidget * )
- void refresh ()

## Protected Members

- void childInsertEvent ( QChildEvent * )
- void childRemoveEvent ( QChildEvent * )
- void layoutHintEvent ( QEvent * )
- virtual void resizeEvent ( QResizeEvent * )
- void moveSplitter ( QCOORD pos )
- virtual void drawSplitter ( QPainter *, QCOORD x, QCOORD y, QCOORD w, QCOORD h )
- int adjustPos ( int )
- void setRubberband ( int )

## Detailed Description

QSplitter implements a splitter widget.

A splitter lets the user control the size of child widgets by dragging the boundary between the children.

The current implementation is limited to two children. The two widgets to be managed are the first two children added. If you need to split more than two widgets, you can nest splitters (although it may be difficult to control the relative sizing to your requirements).

To show a QListBox and a QMultiLineEdit side by side:

        QSplitter *split = new QSplitter( parent );
        QListBox *lb = new QListBox( split );
        QMultiLineEdit *lb = new QMultiLineEdit( split );

In QSplitter the boundary can be either horizontal or vertical. The default is horizontal (the children are side by side) and you can use setOrientation( QSplitter::Vertical ) to set it to vertical.

By default, both widgets can be as large or as small as the user wishes. You can naturally use setMinimumSize() and/or setMaximumSize() on the children. Use setResizeMode() to specify that a widget should keep its size when the splitter is resized.

QSplitter normally resizes the children only at the end of a resize operation, but if you call setOpaqueResize( TRUE ), the widgets are resized as often as possible.

See also: QTabBar.

## Member Function Documentation

### QSplitter::QSplitter ( QWidget * parent=0, const char * name=0 )

Creates a horizontal splitter.

### QSplitter::QSplitter ( Orientation o, QWidget * parent=0, const char * name=0 )

Creates splitter with orientation o.

### int QSplitter::adjustPos ( int p ) `[protected]`

Returns the legal position of the splitter closest to p.

### void QSplitter::childInsertEvent ( QChildEvent * c ) `[protected]`

Tells the splitter that a child widget has been inserted.

### void QSplitter::childRemoveEvent ( QChildEvent * c ) `[protected]`

Tells the splitter that a child widget has been removed.

### void QSplitter::drawSplitter ( QPainter * p, QCOORD x, QCOORD y, QCOORD w, QCOORD h ) `[virtual protected]`

Draws the splitter handle in the rectangle described by x, y, w, h using painter p.

### bool QSplitter::event ( QEvent * e ) `[virtual]`

Reimplemented to provide childRemoveEvent(), childInsertEvent() and layoutHintEvent() without breaking binary compatibility.

Reimplemented from QObject.

### void QSplitter::layoutHintEvent ( QEvent * ) `[protected]`

Tells the splitter that a child widget has changed layout parameters.

### void QSplitter::moveSplitter ( QCOORD p ) `[protected]`

Moves the left/top edge of the splitter handle as close as possible to p which is the distance from the left (or top) edge of the widget.

Only has effect if both widgets are set.

### void QSplitter::moveToFirst ( QWidget * w )

Moves w to the leftmost/top position.

### void QSplitter::moveToLast ( QWidget * w )

Moves w to the rightmost/bottom position.

### bool QSplitter::opaqueResize () const

Returns TRUE if opaque resize is on, FALSE otherwise.

See also: setOpaqueResize().

### QSplitter::Orientation QSplitter::orientation() const

Returns the orientation (`Horizontal` or `Vertical)` of the splitter.

See also: setOrientation().

### void QSplitter::refresh ()

Updates the splitter state. You should not need to call this function during normal operations.

### void QSplitter::setOpaqueResize ( bool on = TRUE )

Sets opaque resize to on. Opaque resize is initially turned off.

See also: opaqueResize().

### void QSplitter::setOrientation ( Orientation o )

Sets the orientation to o. By default the orientation is horizontal (the two widgets are side by side).

See also: orientation().

### void QSplitter::setResizeMode ( QWidget * w, ResizeMode mode )

Sets resize mode of w to mode. mode can be one of:

- `Stretch` (the default) - w will resize when the splitter resizes
- `KeepSize` - w will keep its size.

### void QSplitter::setRubberband ( int p ) `[protected]`

Shows a rubber band at position p. If p is negative, the rubber band is removed.

Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):

This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.

It was generated from the following files:

- qsplitter.h: 1998/08/19
- qsplitter.cpp: 1999/01/05