Class: QgsDockWidget

A QDockWidget subclass with more fine-grained control over how the widget is closed or opened.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsDockWidget

Base classes

QDockWidget

QWidget

QObject

QPaintDevice

Subclasses

QgsAdvancedDigitizingDockWidget

A dockable widget used to handle the CAD tools on top of a selection of map tools.

QgsBrowserDockWidget

A dock widget containing a QgsBrowserWidget for navigating and managing data sources.

Methods

isUserVisible

Returns True if the dock is both opened and raised to the front (ie not hidden by any other tabs.

setToggleVisibilityAction

Links an action to the dock, so that toggling the action will automatically set the dock's visibility to suit (and changing the dock visibility will update the action's state).

setUserVisible

Sets the dock widget as visible to a user, ie both shown and raised to the front.

toggleUserVisible

Toggles whether the dock is user visible.

toggleVisibilityAction

Returns the action linked to the dock.

Signals

closed

Emitted when dock widget is closed.

closedStateChanged

Emitted when dock widget is closed (or opened).

opened

Emitted when dock widget is opened.

openedStateChanged

Emitted when dock widget is opened (or closed).

class qgis.gui.QgsDockWidget[source]

Bases: QDockWidget

__init__(parent: QWidget | None = None, flags: Qt.WindowFlags | Qt.WindowType = Qt.WindowFlags())

Constructor for QgsDockWidget.

Parameters:
  • parent (Optional[QWidget] = None) – parent widget

  • flags (Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()) – window flags

__init__(title: str | None, parent: QWidget | None = None, flags: Qt.WindowFlags | Qt.WindowType = Qt.WindowFlags())

Constructor for QgsDockWidget.

Parameters:
  • title (Optional[str]) – dock title

  • parent (Optional[QWidget] = None) – parent widget

  • flags (Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()) – window flags

signal closed[source]

Emitted when dock widget is closed.

See also

opened()

signal closedStateChanged(wasClosed: bool)[source]

Emitted when dock widget is closed (or opened).

Parameters:

wasClosed (bool) – will be True if dock widget was closed, or False if dock widget was opened

See also

closed()

isUserVisible(self) bool[source]

Returns True if the dock is both opened and raised to the front (ie not hidden by any other tabs.

See also

setUserVisible()

Return type:

bool

signal opened[source]

Emitted when dock widget is opened.

See also

closed()

signal openedStateChanged(wasOpened: bool)[source]

Emitted when dock widget is opened (or closed).

Parameters:

wasOpened (bool) – will be True if dock widget was opened, or False if dock widget was closed

See also

opened()

setToggleVisibilityAction(self, action: QAction | None)[source]

Links an action to the dock, so that toggling the action will automatically set the dock’s visibility to suit (and changing the dock visibility will update the action’s state).

Added in version 3.4.

Parameters:

action (Optional[QAction])

setUserVisible(self, visible: bool)[source]

Sets the dock widget as visible to a user, ie both shown and raised to the front.

Parameters:

visible (bool) –

set to True to show the dock to the user, or False to hide the dock. When setting a dock as user visible, the dock will be opened (if it is not already opened) and raised to the front. When setting as hidden, the following logic is used:

  • hiding a dock which is open but not raised (ie hidden by another tab) will have no effect, and the dock will still be opened and hidden by the other tab

  • hiding a dock which is open and raised (ie, user visible) will cause the dock to be closed

  • hiding a dock which is closed has no effect and raises no signals

See also

isUserVisible()

toggleUserVisible(self)[source]

Toggles whether the dock is user visible. If the dock is not currently user visible (i.e. opened and activated as a tab) then the dock will be opened and raised. If it is currently user visible it will be closed.

See also

setUserVisible()

See also

isUserVisible()

Added in version 3.2.

toggleVisibilityAction(self) QAction | None[source]

Returns the action linked to the dock.

Added in version 3.4.

Return type:

Optional[QAction]