Class: QgsPanelWidgetStack

A stack widget to manage multiple overlapping stacked panels.

Handles the open and close events for added panels.

Any widgets that want to have a non blocking panel based interface should use this class to manage the panels.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsPanelWidgetStack

Base classes

QWidget

QObject

QPaintDevice

Methods

acceptAllPanels

Accepts all panel widgets open in the stack in turn until only the mainPanel() remains.

acceptCurrentPanel

Accept the current active widget in the stack.

clear

Clear the stack of all widgets.

closePanel

Closes the panel in the widget.

currentPanel

Returns the panel currently shown in the stack.

mainPanel

The main panel widget that is set in the stack.

setMainPanel

Sets the main panel widget for the stack and selects it for the user.

showPanel

Show a panel in the stack widget.

takeMainPanel

Removes the main panel widget from the stack and transfers ownsership to the caller.

class qgis.gui.QgsPanelWidgetStack[source]

Bases: QWidget

__init__(parent: QWidget | None = None)

A stack widget to manage panels in the interface. Handles the open and close events for added panels.

Parameters:

parent (Optional[QWidget] = None)

acceptAllPanels(self)[source]

Accepts all panel widgets open in the stack in turn until only the mainPanel() remains.

acceptCurrentPanel(self)[source]

Accept the current active widget in the stack.

Calls the panelAccepeted signal on the active widget.

clear(self)[source]

Clear the stack of all widgets. Unless the panels autoDelete is set to False the widget will be deleted.

closePanel(self, panel: QgsPanelWidget | None)[source]

Closes the panel in the widget. Will also delete the widget. This slot is normally auto connected to panelAccepted when a panel is shown.

Parameters:

panel (Optional[QgsPanelWidget]) – The panel to close.

currentPanel(self) QgsPanelWidget | None[source]

Returns the panel currently shown in the stack.

Return type:

Optional[QgsPanelWidget]

mainPanel(self) QgsPanelWidget | None[source]

The main panel widget that is set in the stack. The main widget can not be closed and doesn’t display a back button.

Return type:

Optional[QgsPanelWidget]

Returns:

The main QgsPanelWidget that is active in the stack.

See also

setMainPanel()

setMainPanel(self, panel: QgsPanelWidget | None)[source]

Sets the main panel widget for the stack and selects it for the user.

The main widget cannot be closed and only the showPanel signal is attached to handle children widget opening panels.

Ownership of panel is transferred to the stack.

Note

a stack can have only one main panel. Any existing main panel should be removed by first calling takeMainPanel().

See also

mainPanel()

See also

takeMainPanel()

Parameters:

panel (Optional[QgsPanelWidget])

showPanel(self, panel: QgsPanelWidget | None)[source]

Show a panel in the stack widget. Will connect to the panels showPanel event to handle nested panels. Auto switches the the given panel for the user.

Parameters:

panel (Optional[QgsPanelWidget]) – The panel to show.

takeMainPanel(self) QgsPanelWidget | None[source]

Removes the main panel widget from the stack and transfers ownsership to the caller.

Return type:

Optional[QgsPanelWidget]

Returns:

The main widget that is set in the stack.

Note

Calling this will clear out any current stacked panels by accepting each panel in turn.

See also

mainPanel()

See also

setMainPanel()