Class: QgsMessageBarItem¶
Represents an item shown within a QgsMessageBar widget.
QgsMessageBarItem represents a single item (or message)
which can be shown in a QgsMessageBar widget.
Class Hierarchy¶
Base classes¶
- class qgis.gui.QgsMessageBarItem[source]¶
Bases:
QWidget- __init__(text: str | None, level: Qgis.MessageLevel = Qgis.MessageLevel.Info, duration: int = 0, parent: QWidget | None = None)
Constructor for QgsMessageBarItem, containing a message with the specified
textto be displayed on the bar.The
levelargument specifies the desired message level (severity) of the message, which controls how the message bar is styled when the item is displayed.The optional
durationargument can be used to specify the message timeout in seconds. Ifdurationis set to 0, then the message must be manually dismissed by the user. Since QGIS 3.18, a duration of -1 indicates that the default timeout for the messagelevelshould be used.- Parameters:
text (Optional[str])
level (Qgis.MessageLevel = Qgis.MessageLevel.Info)
duration (int = 0)
parent (Optional[QWidget] = None)
- __init__(title: str | None, text: str | None, level: Qgis.MessageLevel = Qgis.MessageLevel.Info, duration: int = 0, parent: QWidget | None = None)
Constructor for QgsMessageBarItem, containing a
titleand message with the specifiedtextto be displayed on the bar.The
levelargument specifies the desired message level (severity) of the message, which controls how the message bar is styled when the item is displayed.The optional
durationargument can be used to specify the message timeout in seconds. Ifdurationis set to 0, then the message must be manually dismissed by the user. Since QGIS 3.18, a duration of -1 indicates that the default timeout for the messagelevelshould be used.- Parameters:
title (Optional[str])
text (Optional[str])
level (Qgis.MessageLevel = Qgis.MessageLevel.Info)
duration (int = 0)
parent (Optional[QWidget] = None)
- __init__(title: str | None, text: str | None, widget: QWidget | None, level: Qgis.MessageLevel = Qgis.MessageLevel.Info, duration: int = 0, parent: QWidget | None = None)
Constructor for QgsMessageBarItem, containing a
title, message with the specifiedtext, and a customwidgetto be displayed on the bar.The
levelargument specifies the desired message level (severity) of the message, which controls how the message bar is styled when the item is displayed.The optional
durationargument can be used to specify the message timeout in seconds. Ifdurationis set to 0, then the message must be manually dismissed by the user. Since QGIS 3.18, a duration of -1 indicates that the default timeout for the messagelevelshould be used.- Parameters:
title (Optional[str])
text (Optional[str])
widget (Optional[QWidget])
level (Qgis.MessageLevel = Qgis.MessageLevel.Info)
duration (int = 0)
parent (Optional[QWidget] = None)
- __init__(widget: QWidget | None, level: Qgis.MessageLevel = Qgis.MessageLevel.Info, duration: int = 0, parent: QWidget | None = None)
Constructor for QgsMessageBarItem, containing a custom
widgetto be displayed on the bar.The
levelargument specifies the desired message level (severity) of the message, which controls how the message bar is styled when the item is displayed.The optional
durationargument can be used to specify the message timeout in seconds. Ifdurationis set to 0, then the message must be manually dismissed by the user. Since QGIS 3.18, a duration of -1 indicates that the default timeout for the messagelevelshould be used.- Parameters:
widget (Optional[QWidget])
level (Qgis.MessageLevel = Qgis.MessageLevel.Info)
duration (int = 0)
parent (Optional[QWidget] = None)
- dismiss(self)[source]¶
Dismisses the item, removing it from the message bar and deleting it. Calling this on items which have not been added to a message bar has no effect.
Added in version 3.4.
- duration(self) int[source]¶
Returns the duration (in seconds) of the message.
If the duration is 0 then the message will not automatically timeout and instead must be manually dismissed by the user.
See also
- Return type:
int
- getStyleSheet(self) str[source]¶
Returns the styleSheet which should be used to style a
QgsMessageBarobject when this item is displayed.- Return type:
str
- level(self) Qgis.MessageLevel[source]¶
Returns the message level for the message.
See also
- Return type:
- setDuration(self, duration: int) QgsMessageBarItem | None[source]¶
Sets the
duration(in seconds) to show the message for. Ifdurationis 0 then the message will not automatically timeout and instead must be manually dismissed by the user.See also
- Parameters:
duration (int)
- Return type:
Optional[QgsMessageBarItem]
- setIcon(self, icon: QIcon) QgsMessageBarItem | None[source]¶
Sets the
iconassociated with the message.See also
- Parameters:
icon (QIcon)
- Return type:
Optional[QgsMessageBarItem]
- setLevel(self, level: Qgis.MessageLevel) QgsMessageBarItem | None[source]¶
Sets the message
levelfor the item, which controls how the message bar is styled when the item is displayed.See also
- Parameters:
level (Qgis.MessageLevel)
- Return type:
Optional[QgsMessageBarItem]
- setText(self, text: str | None) QgsMessageBarItem | None[source]¶
Sets the message
textto show in the item.See also
- Parameters:
text (Optional[str])
- Return type:
Optional[QgsMessageBarItem]
- setTitle(self, title: str | None) QgsMessageBarItem | None[source]¶
Sets the
titlefor in the item.See also
- Parameters:
title (Optional[str])
- Return type:
Optional[QgsMessageBarItem]
- setWidget(self, widget: QWidget | None) QgsMessageBarItem | None[source]¶
Sets a custom
widgetto show in the item.See also
- Parameters:
widget (Optional[QWidget])
- Return type:
Optional[QgsMessageBarItem]
- signal styleChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.