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.
enum | HandlePosition { Normal, Reverse } |
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 ) |
virtual bool | eventFilter ( QObject * o, QEvent * e ) |
void | lineUp ( bool keepNewLines ) |
QTextStream & | operator<< ( QTextStream & ts, const Q3DockArea & dockArea ) |
QTextStream & | operator>> ( QTextStream & ts, Q3DockArea & dockArea ) |
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.
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;
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. |
This property holds the number of dock windows in the dock area.
Access functions:
int | count () const |
This property holds whether the dock area is empty.
Access functions:
bool | isEmpty () const |
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 |
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 |
Constructs a Q3DockArea with orientation o, HandlePosition h, parent parent and called name.
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.
Returns a list of the dock windows in the dock area.
Reimplemented from QObject::eventFilter().
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.
Returns true if dock window dw could be docked into the dock area; otherwise returns false.
See also setAcceptDockWindow().
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.
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.
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.
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.
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().
Writes the layout of the dock windows in dock area dockArea to the text stream ts.
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.