Class: QgsMessageBarItem¶
- class qgis.gui.QgsMessageBarItem¶
Bases:
PyQt5.QtWidgets.QWidget
Represents an item shown within a
QgsMessageBar
widget.QgsMessageBarItem
represents a single item (or message) which can be shown in aQgsMessageBar
widget.QgsMessageBarItem(text: str, level: Qgis.MessageLevel = Qgis.MessageLevel.Info, duration: int = 0, parent: QWidget = None) Constructor for
QgsMessageBarItem
, containing a message with the specifiedtext
to be displayed on the bar.The
level
argument specifies the desired message level (severity) of the message, which controls how the message bar is styled when the item is displayed.The optional
duration
argument can be used to specify the message timeout in seconds. Ifduration
is 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 messagelevel
should be used.QgsMessageBarItem(title: str, text: str, level: Qgis.MessageLevel = Qgis.MessageLevel.Info, duration: int = 0, parent: QWidget = None) Constructor for
QgsMessageBarItem
, containing atitle
and message with the specifiedtext
to be displayed on the bar.The
level
argument specifies the desired message level (severity) of the message, which controls how the message bar is styled when the item is displayed.The optional
duration
argument can be used to specify the message timeout in seconds. Ifduration
is 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 messagelevel
should be used.QgsMessageBarItem(title: str, text: str, widget: QWidget, level: Qgis.MessageLevel = Qgis.MessageLevel.Info, duration: int = 0, parent: QWidget = None) Constructor for
QgsMessageBarItem
, containing atitle
, message with the specifiedtext
, and a customwidget
to be displayed on the bar.The
level
argument specifies the desired message level (severity) of the message, which controls how the message bar is styled when the item is displayed.The optional
duration
argument can be used to specify the message timeout in seconds. Ifduration
is 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 messagelevel
should be used.QgsMessageBarItem(widget: QWidget, level: Qgis.MessageLevel = Qgis.MessageLevel.Info, duration: int = 0, parent: QWidget = None) Constructor for
QgsMessageBarItem
, containing a customwidget
to be displayed on the bar.The
level
argument specifies the desired message level (severity) of the message, which controls how the message bar is styled when the item is displayed.The optional
duration
argument can be used to specify the message timeout in seconds. Ifduration
is 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 messagelevel
should be used.Methods
Dismisses the item, removing it from the message bar and deleting it.
Returns the duration (in seconds) of the message.
Returns the styleSheet which should be used to style a
QgsMessageBar
object when this item is displayed.Returns the icon for the message.
Returns the message level for the message.
Sets the
duration
(in seconds) to show the message for.Sets the
icon
associated with the message.Sets the message
level
for the item, which controls how the message bar is styled when the item is displayed.Sets the message
text
to show in the item.Sets the
title
for in the item.Sets a custom
widget
to show in the item.Returns the text for the message.
Returns the title for the message.
Returns the widget for the message.
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- actionEvent(self, QActionEvent)¶
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- closeEvent(self, QCloseEvent)¶
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- customEvent(self, QEvent)¶
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- disconnectNotify(self, QMetaMethod)¶
- dismiss(self)¶
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.
New in version 3.4.
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- dropEvent(self, QDropEvent)¶
- duration(self) int ¶
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
- enterEvent(self, QEvent)¶
- event(self, QEvent) bool ¶
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) bool ¶
- getStyleSheet(self) str ¶
Returns the styleSheet which should be used to style a
QgsMessageBar
object when this item is displayed.- Return type:
str
- hideEvent(self, QHideEvent)¶
- initPainter(self, QPainter)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isSignalConnected(self, QMetaMethod) bool ¶
- keyPressEvent(self, QKeyEvent)¶
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- level(self) Qgis.MessageLevel ¶
Returns the message level for the message.
See also
- Return type:
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int] ¶
- paintEvent(self, QPaintEvent)¶
- receivers(self, PYQT_SIGNAL) int ¶
- resizeEvent(self, QResizeEvent)¶
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setDuration(self, duration: int) QgsMessageBarItem ¶
Sets the
duration
(in seconds) to show the message for. Ifduration
is 0 then the message will not automatically timeout and instead must be manually dismissed by the user.See also
- Parameters:
duration (int) –
- Return type:
- setIcon(self, icon: QIcon) QgsMessageBarItem ¶
Sets the
icon
associated with the message.See also
- Parameters:
icon (QIcon) –
- Return type:
- setLevel(self, level: Qgis.MessageLevel) QgsMessageBarItem ¶
Sets the message
level
for the item, which controls how the message bar is styled when the item is displayed.See also
- Parameters:
level (Qgis.MessageLevel) –
- Return type:
- setText(self, text: str) QgsMessageBarItem ¶
Sets the message
text
to show in the item.See also
- Parameters:
text (str) –
- Return type:
- setTitle(self, title: str) QgsMessageBarItem ¶
Sets the
title
for in the item.See also
- Parameters:
title (str) –
- Return type:
- setWidget(self, widget: QWidget) QgsMessageBarItem ¶
Sets a custom
widget
to show in the item.See also
- Parameters:
widget (QWidget) –
- Return type:
- showEvent(self, QShowEvent)¶
- styleChanged¶
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.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- title(self) str ¶
Returns the title for the message.
See also
- Return type:
str
- updateMicroFocus(self)¶
- wheelEvent(self, QWheelEvent)¶
- widget(self) QWidget ¶
Returns the widget for the message.
See also
- Return type:
QWidget