Qt Jambi Home

com.trolltech.qt.gui
Class QDockWidget

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QWidget
                  extended by com.trolltech.qt.gui.QDockWidget
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QDockWidget
extends QWidget

The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-level window on the desktop.

QDockWidget provides the concept of dock widgets, also know as tool palettes or utility windows. Dock windows are secondary windows placed in the dock widget area around the central widget in a QMainWindow.

Dock windows can be moved inside their current area, moved into new areas and floated (e.g. undocked) by the end-user. The QDockWidget API allows the programmer to restrict the dock widgets ability to move, float and close, as well as the areas in which they can be placed.

Appearance

A QDockWidget consists of a title bar and the content area. The title bar displays the dock widgets window title, a float button and a close button. Depending on the state of the QDockWidget, the float and close buttons may be either disabled or not shown at all.

The visual appearance of the title bar and buttons is dependent on the style in use.

A QDockWidget acts as a wrapper for its child widget, set with setWidget. Custom size hints, minimum and maximum sizes and size policies should be implemented in the child widget. QDockWidget will respect them, adjusting its own constraints to include the frame and title. Size constraints should not be set on the QDockWidget itself, because they change depending on wether it is docked; a docked QDockWidget has no frame and a smaller title bar.

See Also:
QMainWindow, Widgets Example

Nested Class Summary
static class QDockWidget.DockWidgetFeature
          Press link for info on QDockWidget.DockWidgetFeature
static class QDockWidget.DockWidgetFeatures
          This QFlag class provides flags for the int enum.
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal1<Qt.DockWidgetAreas> allowedAreasChanged
          This signal is emitted when the allowedAreas property changes.
 QSignalEmitter.Signal1<Qt.DockWidgetArea> dockLocationChanged
          This signal is emitted when the dock widget is moved to another dock area, or is moved to a different location in its current dock area.
 QSignalEmitter.Signal1<QDockWidget.DockWidgetFeatures> featuresChanged
          This signal is emitted when the features property changes.
 QSignalEmitter.Signal1<java.lang.Boolean> topLevelChanged
          This signal is emitted when the floating property changes.
 QSignalEmitter.Signal1<java.lang.Boolean> visibilityChanged
          This signal is emitted when the dock widget becomes visible (or invisible).
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QDockWidget()
          Equivalent to QDockWidget(0, 0).
QDockWidget(QWidget parent)
          Equivalent to QDockWidget(parent, 0).
QDockWidget(QWidget parent, Qt.WindowFlags flags)
          Constructs a QDockWidget with parent parent and window flags flags.
QDockWidget(java.lang.String title)
          Equivalent to QDockWidget(title, 0, 0).
QDockWidget(java.lang.String title, QWidget parent)
          Equivalent to QDockWidget(title, parent, 0).
QDockWidget(java.lang.String title, QWidget parent, Qt.WindowFlags flags)
          Constructs a QDockWidget with parent parent and window flags flags.
 
Method Summary
 Qt.DockWidgetAreas allowedAreas()
          Returns areas where the dock widget may be placed.
protected  void changeEvent(QEvent event)
          

This event handler can be reimplemented to handle state changes.

protected  void closeEvent(QCloseEvent event)
          

This event handler, for event arg__1, can be reimplemented in a subclass to receive widget close events.

 boolean event(QEvent event)
          

This is the main event handler; it handles event arg__1.

 QDockWidget.DockWidgetFeatures features()
          Returns whether the dock widget is movable, closable, and floatable.
static QDockWidget fromNativePointer(QNativePointer nativePointer)
          This function returns the QDockWidget instance pointed to by nativePointer
protected  void initStyleOption(QStyleOptionDockWidget option)
          Initialize option with the values from this QDockWidget.
 boolean isAreaAllowed(Qt.DockWidgetArea area)
          Returns true if this dock widget can be placed in the given area; otherwise returns false.
 boolean isFloating()
          Returns whether the dock widget is floating.
protected  void paintEvent(QPaintEvent event)
          

This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.

 void setAllowedAreas(Qt.DockWidgetArea... areas)
          Sets areas where the dock widget may be placed to areas.
 void setAllowedAreas(Qt.DockWidgetAreas areas)
          Sets areas where the dock widget may be placed to areas.
 void setFeatures(QDockWidget.DockWidgetFeature... features)
          Sets whether the dock widget is movable, closable, and floatable to features.
 void setFeatures(QDockWidget.DockWidgetFeatures features)
          Sets whether the dock widget is movable, closable, and floatable to features.
 void setFloating(boolean floating)
          Sets whether the dock widget is floating to floating.
 void setTitleBarWidget(QWidget widget)
          Sets an arbitrary widget as the dock widget's title bar.
 void setWidget(QWidget widget)
          Sets the widget for the dock widget to widget.
 QWidget titleBarWidget()
          Returns the custom title bar widget set on the QDockWidget, or 0 if no custom title bar has been set.
 QAction toggleViewAction()
          Returns a checkable action that can be used to show or close this dock widget.
 QWidget widget()
          Returns the widget for the dock widget.
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, contentsRect, contextMenuEvent, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintEngine, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

allowedAreasChanged

public final QSignalEmitter.Signal1<Qt.DockWidgetAreas> allowedAreasChanged

This signal is emitted when the allowedAreas property changes. The allowedAreas parameter gives the new value of the property.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.core.Qt.DockWidgetAreas allowedAreas)
void mySlot()


dockLocationChanged

public final QSignalEmitter.Signal1<Qt.DockWidgetArea> dockLocationChanged

This signal is emitted when the dock widget is moved to another dock area, or is moved to a different location in its current dock area. This happens when the dock widget is moved programmatically or is dragged to a new location by the user.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.core.Qt.DockWidgetArea area)
void mySlot()


featuresChanged

public final QSignalEmitter.Signal1<QDockWidget.DockWidgetFeatures> featuresChanged

This signal is emitted when the features property changes. The features parameter gives the new value of the property.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QDockWidget.DockWidgetFeatures features)
void mySlot()


topLevelChanged

public final QSignalEmitter.Signal1<java.lang.Boolean> topLevelChanged

This signal is emitted when the floating property changes. The topLevel parameter is true if the dock widget is now floating; otherwise it is false.

Compatible Slot Signatures:
void mySlot(boolean topLevel)
void mySlot()
See Also:
isWindow


visibilityChanged

public final QSignalEmitter.Signal1<java.lang.Boolean> visibilityChanged

This signal is emitted when the dock widget becomes visible (or invisible). This happens when the widget is hidden or shown, as well as when it is docked in a tabbed dock area and its tab becomes selected or unselected.

Compatible Slot Signatures:
void mySlot(boolean visible)
void mySlot()

Constructor Detail

QDockWidget

public QDockWidget(java.lang.String title,
                   QWidget parent)

Equivalent to QDockWidget(title, parent, 0).


QDockWidget

public QDockWidget(java.lang.String title)

Equivalent to QDockWidget(title, 0, 0).


QDockWidget

public QDockWidget(java.lang.String title,
                   QWidget parent,
                   Qt.WindowFlags flags)

Constructs a QDockWidget with parent parent and window flags flags. The dock widget will be placed in the left dock widget area.

The window title is set to title. This title is used when the QDockWidget is docked and undocked. It is also used in the context menu provided by QMainWindow.

See Also:
setWindowTitle

QDockWidget

public QDockWidget(QWidget parent)

Equivalent to QDockWidget(parent, 0).


QDockWidget

public QDockWidget()

Equivalent to QDockWidget(0, 0).


QDockWidget

public QDockWidget(QWidget parent,
                   Qt.WindowFlags flags)

Constructs a QDockWidget with parent parent and window flags flags. The dock widget will be placed in the left dock widget area.

Method Detail

allowedAreas

public final Qt.DockWidgetAreas allowedAreas()

Returns areas where the dock widget may be placed.

The default is Qt::AllDockWidgetAreas.

See Also:
setAllowedAreas, Qt::DockWidgetArea

features

public final QDockWidget.DockWidgetFeatures features()

Returns whether the dock widget is movable, closable, and floatable.

See Also:
setFeatures, DockWidgetFeature

isAreaAllowed

public final boolean isAreaAllowed(Qt.DockWidgetArea area)

Returns true if this dock widget can be placed in the given area; otherwise returns false.


isFloating

public final boolean isFloating()

Returns whether the dock widget is floating.

A floating dock widget is presented to the user as an independent window "on top" of its parent QMainWindow, instead of being docked in the QMainWindow.

See Also:
isWindow

setAllowedAreas

public final void setAllowedAreas(Qt.DockWidgetArea... areas)

Sets areas where the dock widget may be placed to areas.

The default is Qt::AllDockWidgetAreas.

See Also:
allowedAreas, Qt::DockWidgetArea

setAllowedAreas

public final void setAllowedAreas(Qt.DockWidgetAreas areas)

Sets areas where the dock widget may be placed to areas.

The default is Qt::AllDockWidgetAreas.

See Also:
allowedAreas, Qt::DockWidgetArea

setFeatures

public final void setFeatures(QDockWidget.DockWidgetFeature... features)

Sets whether the dock widget is movable, closable, and floatable to features.

See Also:
features, DockWidgetFeature

setFeatures

public final void setFeatures(QDockWidget.DockWidgetFeatures features)

Sets whether the dock widget is movable, closable, and floatable to features.

See Also:
features, DockWidgetFeature

setFloating

public final void setFloating(boolean floating)

Sets whether the dock widget is floating to floating.

A floating dock widget is presented to the user as an independent window "on top" of its parent QMainWindow, instead of being docked in the QMainWindow.

See Also:
isFloating, isWindow

setTitleBarWidget

public final void setTitleBarWidget(QWidget widget)

Sets an arbitrary widget as the dock widget's title bar. If widget is 0, the title bar widget is removed, but not deleted.

If a title bar widget is set, QDockWidget will not use native window decorations when it is floated.

Here are some tips for implementing custom title bars:

Using qobject_cast as shown above, the title bar widget has full access to its parent QDockWidget. Hence it can perform such operations as docking and hiding in response to user actions.

See Also:
titleBarWidget, DockWidgetVerticalTitleBar

setWidget

public final void setWidget(QWidget widget)

Sets the widget for the dock widget to widget.

See Also:
widget

titleBarWidget

public final QWidget titleBarWidget()

Returns the custom title bar widget set on the QDockWidget, or 0 if no custom title bar has been set.

See Also:
setTitleBarWidget

toggleViewAction

public final QAction toggleViewAction()

Returns a checkable action that can be used to show or close this dock widget.

The action's text is set to the dock widget's window title.

See Also:
QAction::text, QWidget::windowTitle

widget

public final QWidget widget()

Returns the widget for the dock widget. This function returns zero if the widget has not been set.

See Also:
setWidget

changeEvent

protected void changeEvent(QEvent event)

This event handler can be reimplemented to handle state changes.

The state being changed in this event can be retrieved through event arg__1.

Change events include: QEvent::ToolBarChange, QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange, QEvent::WindowTitleChange, QEvent::IconTextChange, QEvent::ModifiedChange, QEvent::MouseTrackingChange, QEvent::ParentChange, QEvent::WindowStateChange, QEvent::LanguageChange, QEvent::LocaleChange, QEvent::LayoutDirectionChange.

Overrides:
changeEvent in class QWidget

closeEvent

protected void closeEvent(QCloseEvent event)

This event handler, for event arg__1, can be reimplemented in a subclass to receive widget close events.

Overrides:
closeEvent in class QWidget
See Also:
event, hide, close, QCloseEvent, Application Example

event

public boolean event(QEvent event)

This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

Overrides:
event in class QWidget
See Also:
closeEvent, focusInEvent, focusOutEvent, enterEvent, keyPressEvent, keyReleaseEvent, leaveEvent, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, moveEvent, paintEvent, resizeEvent, QObject::event, QObject::timerEvent

paintEvent

protected void paintEvent(QPaintEvent event)

This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.

A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint or update, or because the widget was obscured and has now been uncovered, or for many other reasons.

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.

Qt also tries to speed up painting by merging multiple paint events into one. When update is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint does not permit this optimization, so we suggest using update whenever possible.

When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.

The background can be set using setBackgroundRole and setPalette.

From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent to avoid flicker.

Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:

    ...
    extern void qt_x11_set_global_double_buffer(bool);
    qt_x11_set_global_double_buffer(false);
    ...

Note: In general, one should refrain from calling update or repaint inside of paintEvent. For example, calling update or repaint on children inside a paintEvent results in undefined behavior; the child may or may not get a paint event.

Overrides:
paintEvent in class QWidget
See Also:
event, repaint, update, QPainter, QPixmap, QPaintEvent, Analog Clock Example

fromNativePointer

public static QDockWidget fromNativePointer(QNativePointer nativePointer)
This function returns the QDockWidget instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

initStyleOption

protected final void initStyleOption(QStyleOptionDockWidget option)
Initialize option with the values from this QDockWidget. This method is useful for subclasses when they need a QStyleOption, but don't want to fill in all the information themselves.


Qt Jambi Home