![]() |
Home · Overviews · Examples |
The QSplitter class implements a splitter widget. More...
Inherits QFrame.
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:
QSplitter *splitter = new QSplitter(parent); QListView *listview = new QListView; QTreeView *treeview = new QTreeView; QTextEdit *textedit = new QTextEdit; splitter->addWidget(listview); splitter->addWidget(treeview); 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, and QTabWidget.
Copyright © 2008 Trolltech | Trademarks | Qt Jambi 4.3.5_01 |