Class: QgsCollapsibleGroupBox

A groupbox that collapses/expands when toggled and can save its collapsed and checked states.

By default, it auto-saves only its collapsed state to the global settings based on the widget and its parent names.

Holding Alt modifier key when toggling collapsed state will synchronize the toggling across other collapsible group boxes with the same syncGroup string value

Holding Shift modifier key when attempting to toggle collapsed state will expand current group box, then collapse any others with the same syncGroup string value

See also

QgsCollapsibleGroupBoxBasic which does not auto-save states

Note

To add Collapsible properties in promoted QtDesigner widgets, you can add the following “Dynamic properties” by clicking on the green + in the properties palette: bool collapsed, bool saveCollapsedState, bool saveCheckedState, string syncGroup

Class Hierarchy

Inheritance diagram of qgis.gui.QgsCollapsibleGroupBox

Base classes

QgsCollapsibleGroupBoxBasic

A groupbox that collapses/expands when toggled.

QGroupBox

QWidget

QObject

QPaintDevice

Subclasses

QgsExtentGroupBox

Collapsible group box for configuration of extent, typically for a save operation.

Methods

loadState

Will load the collapsed and checked state

saveCheckedState

saveCollapsedState

saveKey

saveState

Will save the collapsed and checked state

setSaveCheckedState

Set this to True to save/restore checked state

setSaveCollapsedState

Sets this to False to not save/restore collapsed state

setSettingGroup

Sets this to a defined string to share save/restore states across different parent dialogs

setSettings

settingGroup

Returns the name of the setting group in which the collapsed state will be saved

class qgis.gui.QgsCollapsibleGroupBox[source]

Bases: QgsCollapsibleGroupBoxBasic

loadState(self)[source]

Will load the collapsed and checked state

The configuration path from which it is loaded is defined by

  • The object name

  • The settingGroup

saveCheckedState(self) bool[source]
Return type:

bool

saveCollapsedState(self) bool[source]
Return type:

bool

saveKey(self) str[source]
Return type:

str

saveState(self)[source]

Will save the collapsed and checked state

The configuration path to which it is saved is defined by

  • The object name

  • The settingGroup

setSaveCheckedState(self, save: bool)[source]

Set this to True to save/restore checked state

Note

only turn on mSaveCheckedState for groupboxes NOT used in multiple places or used as options for different parent objects

Parameters:

save (bool)

setSaveCollapsedState(self, save: bool)[source]

Sets this to False to not save/restore collapsed state

Parameters:

save (bool)

setSettingGroup(self, group: str | None)[source]

Sets this to a defined string to share save/restore states across different parent dialogs

Parameters:

group (Optional[str])

setSettings(self, settings: QgsSettings | None)[source]
Parameters:

settings (Optional[QgsSettings])

settingGroup(self) str[source]

Returns the name of the setting group in which the collapsed state will be saved

Return type:

str