Qt 4.8: Q3DockArea Class Reference

Qt Reference Documentation

# Q3DockArea Class Reference

The Q3DockArea class manages and lays out Q3DockWindows. More...

     #include <Q3DockArea>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Inherits: QWidget.

- List of all members, including inherited members

## Public Types

enum | HandlePosition { Normal, Reverse }

## Properties

- count : const int
- empty : const bool
- handlePosition : const HandlePosition
- orientation : const Qt::Orientation

- 58 properties inherited from QWidget
- 1 property inherited from QObject

## Public Functions

| Q3DockArea ( Qt::Orientation o, HandlePosition h = Normal, QWidget * parent = 0, const char * name = 0 )
| ~Q3DockArea ()
int | count () const
QList<Q3DockWindow *> | dockWindowList () const
HandlePosition | handlePosition () const
bool | hasDockWindow ( Q3DockWindow * w, int * index = 0 )
bool | isDockWindowAccepted ( Q3DockWindow * dw )
bool | isEmpty () const
void | moveDockWindow ( Q3DockWindow * w, int index = -1 )
void | moveDockWindow ( Q3DockWindow * w, const QPoint & p, const QRect & r, bool swap )
Qt::Orientation | orientation () const
void | removeDockWindow ( Q3DockWindow * w, bool makeFloating, bool swap, bool fixNewLines = true )
void | setAcceptDockWindow ( Q3DockWindow * dw, bool accept )

## Reimplemented Public Functions

virtual bool | eventFilter ( QObject * o, QEvent * e )

- 221 public functions inherited from QWidget
- 29 public functions inherited from QObject
- 13 public functions inherited from QPaintDevice

## Public Slots

void | lineUp ( bool keepNewLines )

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

## Related Non-Members

QTextStream & | operator<< ( QTextStream & ts, const Q3DockArea & dockArea )
QTextStream & | operator>> ( QTextStream & ts, Q3DockArea & dockArea )

### Additional Inherited Members

- 1 signal inherited from QWidget
- 1 signal inherited from QObject
- 4 static public members inherited from QWidget
- 7 static public members inherited from QObject
- 37 protected functions inherited from QWidget
- 8 protected functions inherited from QObject
- 1 protected function inherited from QPaintDevice
- 1 protected slot inherited from QWidget

## Detailed Description

The Q3DockArea class manages and lays out Q3DockWindows.

A Q3DockArea is a container which manages a list of Q3DockWindows which it lays out within its area. In cooperation with the Q3DockWindows it is responsible for the docking and undocking of Q3DockWindows and moving them inside the dock area. Q3DockAreas also handle the wrapping of Q3DockWindows to fill the available space as compactly as possible. Q3DockAreas can contain Q3ToolBars since Q3ToolBar is a Q3DockWindow subclass.

QMainWindow contains four Q3DockAreas which you can use for your Q3ToolBars and Q3DockWindows, so in most situations you do not need to use the Q3DockArea class directly. Although QMainWindow contains support for its own dock areas, you can't add new ones. You also can't add a Q3DockArea to your own subclass of QWidget. It won't be shown.

### Lines.

Q3DockArea uses the concept of lines. A line is a horizontal region which may contain dock windows side-by-side. A dock area may have room for more than one line. When dock windows are docked into a dock area they are usually added at the right hand side of the top-most line that has room (unless manually placed by the user). When users move dock windows they may leave empty lines or gaps in non-empty lines. Qt::Dock windows can be lined up to minimize wasted space using the lineUp() function.

The Q3DockArea class maintains a position list of all its child dock windows. Qt::Dock windows are added to a dock area from position 0 onwards. Qt::Dock windows are laid out sequentially in position order from left to right, and in the case of multiple lines of dock windows, from top to bottom. If a dock window is floated it still retains its position since this is where the window will return if the user double clicks its caption. A dock window's position can be determined with hasDockWindow(). The position can be changed with moveDockWindow().

To dock or undock a dock window use Q3DockWindow::dock() and Q3DockWindow::undock() respectively. If you want to control which dock windows can dock in a dock area use setAcceptDockWindow(). To see if a dock area contains a particular dock window use hasDockWindow(); to see how many dock windows a dock area contains use count().

The streaming operators can write the positions of the dock windows in the dock area to a QTextStream. The positions can be read back later to restore the saved positions.

Save the positions to a QTextStream:

     ts << *myDockArea;

Restore the positions from a QTextStream:

     ts >> *myDockArea;

## Member Type Documentation

### enum Q3DockArea::HandlePosition

A dock window has two kinds of handles, the dock window handle used for dragging the dock window, and the splitter handle used to resize the dock window in relation to other dock windows using a splitter. (The splitter handle is only visible for docked windows.)

This enum specifies where the dock window splitter handle is placed in the dock area.

Constant | Value | Description
--- | --- | ---
`Q3DockArea::Normal` | `0` | The splitter handles of dock windows are placed at the right or bottom.
`Q3DockArea::Reverse` | `1` | The splitter handles of dock windows are placed at the left or top.

## Property Documentation

### count : const int

This property holds the number of dock windows in the dock area.

Access functions:

int | count () const

### empty : const bool

This property holds whether the dock area is empty.

Access functions:

bool | isEmpty () const

### handlePosition : const HandlePosition

This property holds where the dock window splitter handle is placed in the dock area.

The default position is `Normal`.

Access functions:

HandlePosition | handlePosition () const

### orientation : const Qt::Orientation

This property holds the dock area's orientation.

There is no default value; the orientation is specified in the constructor.

Access functions:

Qt::Orientation | orientation () const

## Member Function Documentation

### Q3DockArea::Q3DockArea ( Qt::Orientation o, HandlePosition h = Normal, QWidget * parent = 0, const char * name = 0 )

Constructs a Q3DockArea with orientation o, HandlePosition h, parent parent and called name.

### Q3DockArea::~Q3DockArea ()

Destroys the dock area and all the dock windows docked in the dock area.

Does not affect any floating dock windows or dock windows in other dock areas, even if they first appeared in this dock area. Floating dock windows are effectively top level windows and are not child windows of the dock area. When a floating dock window is docked (dragged into a dock area) its parent becomes the dock area.

### QList<Q3DockWindow *> Q3DockArea::dockWindowList () const

Returns a list of the dock windows in the dock area.

### bool Q3DockArea::eventFilter ( QObject * o, QEvent * e )`[virtual]`

Reimplemented from QObject::eventFilter().

### bool Q3DockArea::hasDockWindow ( Q3DockWindow * w, int * index = 0 )

Returns true if the dock area contains the dock window w; otherwise returns false. If index is not 0 it will be set as follows: if the dock area contains the dock window *index is set to w's index position; otherwise *index is set to -1.

### bool Q3DockArea::isDockWindowAccepted ( Q3DockWindow * dw )

Returns true if dock window dw could be docked into the dock area; otherwise returns false.

See also setAcceptDockWindow().

### void Q3DockArea::lineUp ( bool keepNewLines )`[slot]`

Lines up the dock windows in this dock area to minimize wasted space. If keepNewLines is true, only space within lines is cleaned up. If keepNewLines is false the number of lines might be changed.

### void Q3DockArea::moveDockWindow ( Q3DockWindow * w, int index = -1 )

Moves the Q3DockWindow w within the dock area. If w is not already docked in this area, w is docked first. If index is -1 or larger than the number of docked widgets, w is appended at the end, otherwise it is inserted at the position index.

### void Q3DockArea::moveDockWindow ( Q3DockWindow * w, const QPoint & p, const QRect & r, bool swap )

This is an overloaded function.

Moves the dock window w inside the dock area where p is the new position (in global screen coordinates), r is the suggested rectangle of the dock window and swap specifies whether or not the orientation of the docked widget needs to be changed.

This function is used internally by Q3DockWindow. You shouldn't need to call it yourself.

### void Q3DockArea::removeDockWindow ( Q3DockWindow * w, bool makeFloating, bool swap, bool fixNewLines = true )

Removes the dock window w from the dock area. If makeFloating is true, w gets floated, and if swap is true, the orientation of w gets swapped. If fixNewLines is true (the default) newlines in the area will be fixed.

You should never need to call this function yourself. Use Q3DockWindow::dock() and Q3DockWindow::undock() instead.

### void Q3DockArea::setAcceptDockWindow ( Q3DockWindow * dw, bool accept )

If accept is true, dock window dw can be docked in the dock area. If accept is false, dock window dw cannot be docked in the dock area.

See also isDockWindowAccepted().

## Related Non-Members

### QTextStream & operator<< ( QTextStream & ts, const Q3DockArea & dockArea )

Writes the layout of the dock windows in dock area dockArea to the text stream ts.

### QTextStream & operator>> ( QTextStream & ts, Q3DockArea & dockArea )

Reads the layout description of the dock windows in dock area dockArea from the text stream ts and restores it. The layout description must have been previously written by the operator<<() function.