QgsDockWidget class

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

Derived classes

class QgsAdvancedDigitizingDockWidget
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of a selection of map tools.
class QgsBrowserDockWidget
The QgsBrowserDockWidget class.

Constructors, destructors, conversion operators

QgsDockWidget(QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr) explicit
Constructor for QgsDockWidget.
QgsDockWidget(const QString& title, QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr) explicit
Constructor for QgsDockWidget.

Public functions

auto isUserVisible() const -> bool
Returns true if the dock is both opened and raised to the front (ie not hidden by any other tabs.
void setToggleVisibilityAction(QAction* action)
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).
auto toggleVisibilityAction() -> QAction*
Returns the action linked to the dock.

Signals

void closed()
Emitted when dock widget is closed.
void closedStateChanged(bool wasClosed)
Emitted when dock widget is closed (or opened).
void opened()
Emitted when dock widget is opened.
void openedStateChanged(bool wasOpened)
Emitted when dock widget is opened (or closed).

Public slots

void setUserVisible(bool visible)
Sets the dock widget as visible to a user, ie both shown and raised to the front.
void toggleUserVisible()
Toggles whether the dock is user visible.

Function documentation

QgsDockWidget::QgsDockWidget(QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr) explicit

Constructor for QgsDockWidget.

Parameters
parent parent widget
flags window flags

QgsDockWidget::QgsDockWidget(const QString& title, QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr) explicit

Constructor for QgsDockWidget.

Parameters
title dock title
parent parent widget
flags window flags

bool QgsDockWidget::isUserVisible() const

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

void QgsDockWidget::setToggleVisibilityAction(QAction* action)

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).

QAction* QgsDockWidget::toggleVisibilityAction()

Returns the action linked to the dock.

void QgsDockWidget::closed() signal

Emitted when dock widget is closed.

void QgsDockWidget::closedStateChanged(bool wasClosed) signal

Emitted when dock widget is closed (or opened).

Parameters
wasClosed will be true if dock widget was closed, or false if dock widget was opened

void QgsDockWidget::opened() signal

Emitted when dock widget is opened.

void QgsDockWidget::openedStateChanged(bool wasOpened) signal

Emitted when dock widget is opened (or closed).

Parameters
wasOpened will be true if dock widget was opened, or false if dock widget was closed

void QgsDockWidget::setUserVisible(bool visible) public slot

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

Parameters
visible

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

void QgsDockWidget::toggleUserVisible() public slot

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.