Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QSplitter Class Reference

The QSplitter class implements a splitter widget. More...

    #include <QSplitter>

Inherits QFrame.

- List of all members, including inherited members
- Compatibility members

### Writable Properties

- childrenCollapsible : bool
- handleWidth : int
- opaqueResize : bool
- orientation : Qt::Orientation

- 5 writable properties inherited from QFrame
- 33 writable properties inherited from QWidget
- 1 writable property inherited from QObject

### Read-Only Properties

- 1 read-only property inherited from QFrame
- 20 read-only properties inherited from QWidget

### Public Functions

- QSplitter ( QWidget * parent = 0, const char * name = 0 )
- QSplitter ( Qt::Orientation o, QWidget * parent = 0, const char * name = 0 )
- ~QSplitter ()
- void moveToFirst ( QWidget * w )
- void moveToLast ( QWidget * w )
- void refresh ()
- void setCollapsible ( QWidget * w, bool collapse )
- void setSizes ( const QList<int> & list )
- QList<int> sizes () const

- 2 public functions inherited from QFrame
- 92 public functions inherited from QWidget
- 26 public functions inherited from QObject
- 10 public functions inherited from QPaintDevice

### Public Slots

- 16 public slots inherited from QWidget
- 1 public slot inherited from QObject

### Signals

- 1 signal inherited from QObject

### Static Public Members

- 4 static public members inherited from QWidget
- 4 static public members inherited from QObject

### Protected Functions

- int adjustPos ( int pos, int id )
- virtual void childEvent ( QChildEvent * c )
- void getRange ( int id, int * min, int * max )
- int idAfter ( QWidget * w ) const
- void moveSplitter ( QCOORD p, int id )
- virtual void setRubberband ( int p )

- 42 protected functions inherited from QWidget
- 7 protected functions inherited from QObject

### Related Non-Members

- QTextStream & operator<< ( QTextStream & ts, const QSplitter & splitter )
- QTextStream & operator>> ( QTextStream & ts, QSplitter & splitter )

## 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.

To show a QListBox, a QListView and a QTextEdit side by side:

        QSplitter *split = new QSplitter(parent);
        QListBox *lb = new QListBox(split);
        QListView *lv = new QListView(split);
        QTextEdit *ed = new QTextEdit(split);

QSplitter lays out its children horizontally (side by side); you can use setOrientation(Qt::Vertical) to lay out the children 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. Use setResizeMode() to specify that a widget should keep its size when the splitter is resized, or set the stretch component of the sizePolicy.

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

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.

If you hide() a child its space will be distributed among the other children. It will be reinstated when you show() it again. It is also possible to reorder the widgets within the splitter using moveToFirst() and moveToLast().

See also QTabBar.

## Property Documentation

### childrenCollapsible : bool

This property holds whether child widgets can be resized down to size 0 by the user.

By default, children are collapsible. It is possible to enable and disable the collapsing of individual children; see setCollapsible().

Access functions:

- bool childrenCollapsible () const
- void setChildrenCollapsible ( bool )

### handleWidth : int

This property holds the width of the splitter handle.

Access functions:

- int handleWidth () const
- void setHandleWidth ( int )

### opaqueResize : bool

This property holds whether resizing is opaque.

Opaque resizing is off by default.

Access functions:

- bool opaqueResize () const
- void setOpaqueResize ( bool = true )

### orientation : Qt::Orientation

This property holds the orientation of the splitter.

By default the orientation is horizontal (the widgets are side by side). The possible orientations are `Qt::Horizontal` and `Qt::Vertical`.

Access functions:

- Qt::Orientation orientation () const
- void setOrientation ( Qt::Orientation )

## Member Function Documentation

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

Constructs a horizontal splitter with the parent and name arguments being passed on to the QFrame constructor.

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

Constructs a splitter with orientation o with the parent and name arguments being passed on to the QFrame constructor.

### QSplitter::~QSplitter ()

Destroys the splitter and any children.

### int QSplitter::adjustPos ( int pos, int id ) `[protected]`

Returns the closest legal position to pos of the widget with ID id.

See also idAfter().

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

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

Reimplemented from QObject.

### void QSplitter::getRange ( int id, int * min, int * max ) `[protected]`

Returns the valid range of the splitter with ID id in `*`min and `*`max if min and max are not 0.

See also idAfter().

### int QSplitter::idAfter ( QWidget * w ) const `[protected]`

Returns the ID of the widget to the right of or below the widget w, or 0 if there is no such widget (i.e. it is either not in this QSplitter or w is at the end).

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

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

For Arabic, Hebrew and other right-to-left languages the layout is reversed. p is then the distance from the right (or top) edge of the widget.

See also idAfter().

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

Moves widget w to the leftmost/top position.

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

Moves widget w to the rightmost/bottom position.

### void QSplitter::refresh ()

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

### void QSplitter::setCollapsible ( QWidget * w, bool collapse )

Sets whether the child widget w 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.

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

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

### 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().

### 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.

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

        QList<int> list = mySplitter.sizes();
        QList<int>::Iterator it = list.begin();
        while(it != list.end()) {
            myProcessing(*it);
            ++it;
        }

See also setSizes().

## Related Non-Members

### QTextStream & operator<< ( QTextStream & ts, const QSplitter & splitter )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Writes the sizes and the hidden state of the widgets in the splitter splitter to the text stream ts.

See also operator>>(), sizes(), and QWidget::isHidden().

### QTextStream & operator>> ( QTextStream & ts, QSplitter & splitter )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Reads the sizes and the hidden state of the widgets in the splitter splitter from the text stream ts. The sizes must have been previously written by the operator<<() function.

See also operator<<(), setSizes(), and QWidget::hide().