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 a QgsMessageBar widget.

QgsMessageBarItem(text: str, level: Qgis.MessageLevel = Qgis.Info, duration: int = 0, parent: QWidget = None) Constructor for QgsMessageBarItem, containing a message with the specified text 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. If duration 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 message level should be used.

QgsMessageBarItem(title: str, text: str, level: Qgis.MessageLevel = Qgis.Info, duration: int = 0, parent: QWidget = None) Constructor for QgsMessageBarItem, containing a title and message with the specified text 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. If duration 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 message level should be used.

QgsMessageBarItem(title: str, text: str, widget: QWidget, level: Qgis.MessageLevel = Qgis.Info, duration: int = 0, parent: QWidget = None) Constructor for QgsMessageBarItem, containing a title, message with the specified text, and a custom widget 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. If duration 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 message level should be used.

QgsMessageBarItem(widget: QWidget, level: Qgis.MessageLevel = Qgis.Info, duration: int = 0, parent: QWidget = None) Constructor for QgsMessageBarItem, containing a custom widget 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. If duration 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 message level should be used.

Methods

actionEvent

changeEvent

childEvent

closeEvent

connectNotify

contextMenuEvent

create

customEvent

destroy

disconnectNotify

dismiss

Dismisses the item, removing it from the message bar and deleting it.

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

duration

Returns the duration (in seconds) of the message.

enterEvent

event

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

getStyleSheet

Returns the styleSheet which should be used to style a QgsMessageBar object when this item is displayed.

hideEvent

icon

Returns the icon for the message.

initPainter

inputMethodEvent

isSignalConnected

keyPressEvent

keyReleaseEvent

leaveEvent

level

Returns the message level for the message.

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

nativeEvent

paintEvent

receivers

resizeEvent

sender

senderSignalIndex

setDuration

Sets the duration (in seconds) to show the message for.

setIcon

Sets the icon associated with the message.

setLevel

Sets the message level for the item, which controls how the message bar is styled when the item is displayed.

setText

Sets the message text to show in the item.

setTitle

Sets the title for in the item.

setWidget

Sets a custom widget to show in the item.

sharedPainter

showEvent

tabletEvent

text

Returns the text for the message.

timerEvent

title

Returns the title for the message.

updateMicroFocus

wheelEvent

widget

Returns the widget for the message.

Signals

styleChanged

Emitted when the item’s message level has changed and the message bar style will need to be updated as a result.

actionEvent(self, QActionEvent)
changeEvent(self, QEvent)
childEvent(self, QChildEvent)
closeEvent(self, QCloseEvent)
connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)
create(self, window: 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

setDuration()

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)
icon(self)QIcon

Returns the icon for the message.

See also

setIcon()

Return type

QIcon

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

setLevel()

Return type

Qgis.MessageLevel

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], 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. If duration is 0 then the message will not automatically timeout and instead must be manually dismissed by the user.

See also

duration()

Parameters

duration (int) –

Return type

QgsMessageBarItem

setIcon(self, icon: QIcon)QgsMessageBarItem

Sets the icon associated with the message.

See also

icon()

Parameters

icon (QIcon) –

Return type

QgsMessageBarItem

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

level()

Parameters

level (Qgis.MessageLevel) –

Return type

QgsMessageBarItem

setText(self, text: str)QgsMessageBarItem

Sets the message text to show in the item.

See also

text()

Parameters

text (str) –

Return type

QgsMessageBarItem

setTitle(self, title: str)QgsMessageBarItem

Sets the title for in the item.

See also

title()

Parameters

title (str) –

Return type

QgsMessageBarItem

setWidget(self, widget: QWidget)QgsMessageBarItem

Sets a custom widget to show in the item.

See also

widget()

Parameters

widget (QWidget) –

Return type

QgsMessageBarItem

sharedPainter(self)QPainter
showEvent(self, QShowEvent)
styleChanged

Emitted when the item’s message level has changed and the message bar style will need to be updated as a result. [signal]

Parameters

styleSheet (str) –

tabletEvent(self, QTabletEvent)
text(self)str

Returns the text for the message.

See also

setText()

Return type

str

timerEvent(self, QTimerEvent)
title(self)str

Returns the title for the message.

See also

setTitle()

Return type

str

updateMicroFocus(self)
wheelEvent(self, QWheelEvent)
widget(self)QWidget

Returns the widget for the message.

See also

setWidget()

Return type

QWidget