Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

QSplitter Class Reference

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

#include </home/clem/local/src/opie/libqtaux/qsplitter.h>

Collaboration diagram for QSplitter:

Collaboration graph
[legend]
List of all members.

Public Types

enum  ResizeMode { Stretch, KeepSize, FollowSizeHint }

Public Member Functions

 QSplitter (QWidget *parent=0, const char *name=0)
 QSplitter (Orientation, QWidget *parent=0, const char *name=0)
 ~QSplitter ()
virtual void setOrientation (Orientation)
Orientation orientation () const
virtual void setResizeMode (QWidget *w, ResizeMode)
virtual void setOpaqueResize (bool=TRUE)
bool opaqueResize () const
void moveToFirst (QWidget *)
void moveToLast (QWidget *)
void refresh ()
QSize sizeHint () const
QSize minimumSizeHint () const
QSizePolicy sizePolicy () const
QValueList< int > sizes () const
void setSizes (QValueList< int >)

Protected Member Functions

void childEvent (QChildEvent *)
bool event (QEvent *)
void resizeEvent (QResizeEvent *)
int idAfter (QWidget *) const
void moveSplitter (QCOORD pos, int id)
virtual void drawSplitter (QPainter *, QCOORD x, QCOORD y, QCOORD w, QCOORD h)
void styleChange (QStyle &)
int adjustPos (int, int)
virtual void setRubberband (int)
void getRange (int id, int *, int *)

Properties

Orientation orientation

Private Member Functions

void init ()
void recalc (bool update=FALSE)
void doResize ()
void storeSizes ()
void processChildEvents ()
QSplitterLayoutStructaddWidget (QWidget *, bool first=FALSE)
void recalcId ()
void moveBefore (int pos, int id, bool upLeft)
void moveAfter (int pos, int id, bool upLeft)
void setG (QWidget *w, int p, int s)
QCOORD pick (const QPoint &p) const
QCOORD pick (const QSize &s) const
QCOORD trans (const QPoint &p) const
QCOORD trans (const QSize &s) const

Private Attributes

QSplitterDatadata
Orientation orient

Friends

class QSplitterHandle

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.

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

    QSplitter *split = new QSplitter( parent );
    QListBox *lb = new QListBox( split );
    QListView *lv = new QListView( split );
    QMultiLineEdit *ed = 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, all widgets can be as large or as small as the user wishes, down to minimumSizeHint(). 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.

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. When you show() it again, it will be reinstated.

qsplitter-m.png
qsplitter-w.png

See also:
QTabBar

Definition at line 49 of file qsplitter.h.


Member Enumeration Documentation

enum QSplitter::ResizeMode
 

This enum type describes how QSplitter will resize each of its child widgets. The currently defined values are:

  • Stretch - the widget will be resized when the splitter itself is resized.

  • KeepSize - QSplitter will try to keep this widget's size unchanged.

  • FollowSizeHint - QSplitter will resize the widget when its size hint changes.

Enumeration values:
Stretch 
KeepSize 
FollowSizeHint 

Definition at line 55 of file qsplitter.h.


Constructor & Destructor Documentation

QSplitter::QSplitter QWidget *  parent = 0,
const char *  name = 0
 

Constructs a horizontal splitter.

Definition at line 233 of file qsplitter.cpp.

References init(), and orient.

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

Constructs splitter with orientation o.

Definition at line 245 of file qsplitter.cpp.

References init(), and orient.

QSplitter::~QSplitter  ) 
 

Destructs the splitter.

Definition at line 257 of file qsplitter.cpp.

References data, QSplitterData::list, and TRUE.


Member Function Documentation

QSplitterLayoutStruct * QSplitter::addWidget QWidget *  w,
bool  first = FALSE
[private]
 

Inserts the widget w at the end, or at the beginning if first is TRUE

It is the responsibility of the caller of this function to make sure that w is not already in the splitter, and to call recalcId if needed. (If first is TRUE, then recalcId is very probably needed.)

Definition at line 334 of file qsplitter.cpp.

References data, FALSE, QSplitterLayoutStruct::isSplitter, KeepSize, QSplitterData::list, QSplitterLayoutStruct::mode, orientation(), pick(), QSplitterHandle, s, QSplitterHandle::setId(), QSplitterHandle::sizeHint(), QSplitterLayoutStruct::sizer, Stretch, TRUE, and QSplitterLayoutStruct::wid.

Referenced by childEvent(), moveToFirst(), moveToLast(), and setResizeMode().

int QSplitter::adjustPos int  p,
int  id
[protected]
 

Returns the legal position closest to p of the splitter with id id.

See also:
idAfter()

Definition at line 654 of file qsplitter.cpp.

References getRange(), max, and min.

Referenced by moveSplitter().

void QSplitter::childEvent QChildEvent *  c  )  [protected]
 

Tells the splitter that a child widget has been inserted/removed.

Definition at line 373 of file qsplitter.cpp.

References addWidget(), data, doResize(), QSplitterLayoutStruct::isSplitter, QSplitterData::list, p, recalc(), recalcId(), s, and QSplitterLayoutStruct::wid.

void QSplitter::doResize  )  [private]
 

Definition at line 665 of file qsplitter.cpp.

References data, FALSE, FollowSizeHint, i, QSplitterLayoutStruct::isSplitter, KeepSize, QSplitterData::list, minSize(), QSplitterLayoutStruct::mode, orient, pick(), pos, qGeomCalc(), s, QSplitterLayoutStruct::sizer, and QSplitterLayoutStruct::wid.

Referenced by childEvent(), recalc(), resizeEvent(), setSizes(), and styleChange().

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

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

See also:
QStyle::drawSplitter

Definition at line 466 of file qsplitter.cpp.

References orient.

Referenced by QSplitterHandle::paintEvent().

bool QSplitter::event QEvent *  e  )  [protected]
 

Definition at line 449 of file qsplitter.cpp.

References data, FALSE, QSplitterData::firstShow, and recalc().

void QSplitter::getRange int  id,
int *  min,
int *  max
[protected]
 

Returns the valid range of the splitter with id id in min and max.

See also:
idAfter()

Definition at line 605 of file qsplitter.cpp.

References data, i, QSplitterLayoutStruct::isSplitter, QSplitterData::list, minSize(), pick(), s, QSplitterLayoutStruct::sizer, and QSplitterLayoutStruct::wid.

Referenced by adjustPos(), and QSplitterHandle::mouseMoveEvent().

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

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

Definition at line 479 of file qsplitter.cpp.

References data, FALSE, QSplitterLayoutStruct::isSplitter, QSplitterData::list, s, TRUE, and QSplitterLayoutStruct::wid.

void QSplitter::init  )  [private]
 

Definition at line 264 of file qsplitter.cpp.

References data, and orient.

Referenced by QSplitter().

QSize QSplitter::minimumSizeHint  )  const
 

Definition at line 942 of file qsplitter.cpp.

References l, minSize(), o, orientation(), pick(), s, t, and trans().

void QSplitter::moveAfter int  pos,
int  id,
bool  upLeft
[private]
 

Places the left/top edge of the widget at id at position pos.

See also:
idAfter()

Definition at line 566 of file qsplitter.cpp.

References data, QSplitterLayoutStruct::isSplitter, QSplitterData::list, minSize(), pick(), s, setG(), QSplitterLayoutStruct::sizer, and QSplitterLayoutStruct::wid.

Referenced by moveSplitter().

void QSplitter::moveBefore int  pos,
int  id,
bool  upLeft
[private]
 

Places the right/bottom edge of the widget at id at position pos.

See also:
idAfter()

Definition at line 531 of file qsplitter.cpp.

References data, QSplitterLayoutStruct::isSplitter, QSplitterData::list, minSize(), pick(), s, setG(), QSplitterLayoutStruct::sizer, and QSplitterLayoutStruct::wid.

Referenced by moveSplitter().

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 p which is the distance from the left (or top) edge of the widget.

See also:
idAfter()

Definition at line 501 of file qsplitter.cpp.

References adjustPos(), data, QSplitterData::list, moveAfter(), moveBefore(), orient, s, storeSizes(), and QSplitterLayoutStruct::wid.

Referenced by QSplitterHandle::mouseMoveEvent(), and QSplitterHandle::mouseReleaseEvent().

void QSplitter::moveToFirst QWidget *  w  ) 
 

Moves w to the leftmost/top position.

Definition at line 845 of file qsplitter.cpp.

References addWidget(), data, FALSE, QSplitterData::list, p, processChildEvents(), recalcId(), s, TRUE, and QSplitterLayoutStruct::wid.

void QSplitter::moveToLast QWidget *  w  ) 
 

Moves w to the rightmost/bottom position.

Definition at line 874 of file qsplitter.cpp.

References addWidget(), data, FALSE, QSplitterData::list, p, processChildEvents(), recalcId(), s, TRUE, and QSplitterLayoutStruct::wid.

bool QSplitter::opaqueResize  )  const
 

Returns TRUE if opaque resize is on, FALSE otherwise.

See also:
setOpaqueResize()

Definition at line 823 of file qsplitter.cpp.

References data, and QSplitterData::opaque.

Referenced by QSplitterHandle::opaque().

Orientation QSplitter::orientation  )  const [inline]
 

Definition at line 62 of file qsplitter.h.

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

QCOORD QSplitter::pick const QSize &  s  )  const [inline, private]
 

Definition at line 109 of file qsplitter.h.

QCOORD QSplitter::pick const QPoint &  p  )  const [inline, private]
 

Definition at line 107 of file qsplitter.h.

Referenced by addWidget(), doResize(), getRange(), minimumSizeHint(), QSplitterHandle::mouseMoveEvent(), QSplitterHandle::mousePressEvent(), QSplitterHandle::mouseReleaseEvent(), moveAfter(), moveBefore(), recalc(), sizeHint(), and storeSizes().

void QSplitter::processChildEvents  )  [private]
 

Gets all posted child events, ensuring that the internal state of the splitter is consistent with the programmer's idea.

Definition at line 1102 of file qsplitter.cpp.

Referenced by moveToFirst(), moveToLast(), setResizeMode(), and setSizes().

void QSplitter::recalc bool  update = FALSE  )  [private]
 

Definition at line 713 of file qsplitter.cpp.

References data, doResize(), empty, FALSE, i, QSplitterLayoutStruct::isSplitter, QSplitterData::list, minSize(), orient, p, pick(), s, QSplitterLayoutStruct::sizer, trans(), TRUE, and QSplitterLayoutStruct::wid.

Referenced by childEvent(), event(), and setOrientation().

void QSplitter::recalcId  )  [private]
 

Definition at line 899 of file qsplitter.cpp.

References data, i, QSplitterLayoutStruct::isSplitter, QSplitterData::list, s, and QSplitterLayoutStruct::wid.

Referenced by childEvent(), moveToFirst(), and moveToLast().

void QSplitter::refresh  )  [inline]
 

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

Definition at line 71 of file qsplitter.h.

References TRUE.

void QSplitter::resizeEvent QResizeEvent *   )  [protected]
 

Definition at line 319 of file qsplitter.cpp.

References doResize().

void QSplitter::setG QWidget *  w,
int  p,
int  s
[private]
 

Definition at line 516 of file qsplitter.cpp.

References height, orient, width, Opie::MM::x, and Opie::MM::y.

Referenced by moveAfter(), and moveBefore().

void QSplitter::setOpaqueResize bool  on = TRUE  )  [virtual]
 

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

See also:
opaqueResize()

Definition at line 835 of file qsplitter.cpp.

References data, and QSplitterData::opaque.

void QSplitter::setOrientation Orientation  o  )  [virtual]
 

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

See also:
orientation()

Definition at line 288 of file qsplitter.cpp.

References data, QSplitterLayoutStruct::isSplitter, QSplitterData::list, orient, recalc(), s, and QSplitterLayoutStruct::wid.

Referenced by ConfigMainWindow::ConfigMainWindow().

void QSplitter::setResizeMode QWidget *  w,
ResizeMode  mode
[virtual]
 

Sets resize mode of w to mode.

See also:
ResizeMode

Definition at line 801 of file qsplitter.cpp.

References addWidget(), data, QSplitterData::list, QSplitterLayoutStruct::mode, processChildEvents(), s, TRUE, and QSplitterLayoutStruct::wid.

Referenced by OJanusWidget::setTreeListAutoResize(), and OJanusWidget::showEvent().

void QSplitter::setRubberband int  p  )  [protected, virtual]
 

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

Definition at line 421 of file qsplitter.cpp.

References opaqueOldPos, and orient.

Referenced by QSplitterHandle::mouseMoveEvent(), and QSplitterHandle::mouseReleaseEvent().

void QSplitter::setSizes QValueList< int >  list  ) 
 

Sets the size parameters to the values given in list. If the splitter is horizontal, the values set the sizes from left to right. If it is vertical, the sizes are applied from top to bottom. Extra values in list are ignored.

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

See also:
sizes()

Definition at line 1081 of file qsplitter.cpp.

References QValueList< T >::begin(), data, doResize(), QValueList< T >::end(), QSplitterLayoutStruct::isSplitter, QSplitterData::list, processChildEvents(), s, and QSplitterLayoutStruct::sizer.

QSize QSplitter::sizeHint  )  const
 

Definition at line 912 of file qsplitter.cpp.

References l, o, orientation(), pick(), s, t, and trans().

QSizePolicy QSplitter::sizePolicy  )  const
 

Definition at line 971 of file qsplitter.cpp.

QValueList< int > QSplitter::sizes  )  const
 

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

Giving the values to setSizes() will give a splitter with the same layout as this one.

See also:
setSizes()

Definition at line 1050 of file qsplitter.cpp.

References QValueList< T >::append(), data, QSplitterData::list, list, and s.

void QSplitter::storeSizes  )  [private]
 

Calculates stretch parameters from current sizes

Definition at line 981 of file qsplitter.cpp.

References data, QSplitterLayoutStruct::isSplitter, QSplitterData::list, pick(), s, QSplitterLayoutStruct::sizer, and QSplitterLayoutStruct::wid.

Referenced by moveSplitter().

void QSplitter::styleChange QStyle &  old  )  [protected]
 

Definition at line 1112 of file qsplitter.cpp.

References data, doResize(), QSplitterLayoutStruct::isSplitter, QSplitterData::list, s, and QSplitterLayoutStruct::sizer.

QCOORD QSplitter::trans const QSize &  s  )  const [inline, private]
 

Definition at line 114 of file qsplitter.h.

QCOORD QSplitter::trans const QPoint &  p  )  const [inline, private]
 

Definition at line 112 of file qsplitter.h.

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


Friends And Related Function Documentation

friend class QSplitterHandle [friend]
 

Definition at line 120 of file qsplitter.h.

Referenced by addWidget().


Member Data Documentation

QSplitterData* QSplitter::data [private]
 

Definition at line 117 of file qsplitter.h.

Referenced by addWidget(), childEvent(), doResize(), event(), getRange(), idAfter(), init(), moveAfter(), moveBefore(), moveSplitter(), moveToFirst(), moveToLast(), opaqueResize(), recalc(), recalcId(), setOpaqueResize(), setOrientation(), setResizeMode(), setSizes(), sizes(), storeSizes(), styleChange(), and ~QSplitter().

Orientation QSplitter::orient [private]
 

Definition at line 119 of file qsplitter.h.

Referenced by doResize(), drawSplitter(), init(), moveSplitter(), QSplitter(), recalc(), setG(), setOrientation(), and setRubberband().


Property Documentation

Orientation QSplitter::orientation [read, write]
 

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

See also:
setOrientation()

Definition at line 51 of file qsplitter.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:48:55 2005 for OPIE by  doxygen 1.4.2