QGIS API Documentation  3.20.0-Odense (decaadbb31)
Public Slots | Signals | Public Member Functions | Friends | List of all members
QgsMessageBarItem Class Reference

Represents an item shown within a QgsMessageBar widget. More...

#include <qgsmessagebaritem.h>

Inheritance diagram for QgsMessageBarItem:
Inheritance graph
[legend]

Public Slots

void dismiss ()
 Dismisses the item, removing it from the message bar and deleting it. More...
 

Signals

void styleChanged (const QString &styleSheet)
 Emitted when the item's message level has changed and the message bar style will need to be updated as a result. More...
 

Public Member Functions

 QgsMessageBarItem (const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=0, QWidget *parent=nullptr)
 Constructor for QgsMessageBarItem, containing a message with the specified text to be displayed on the bar. More...
 
 QgsMessageBarItem (const QString &title, const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=0, QWidget *parent=nullptr)
 Constructor for QgsMessageBarItem, containing a title and message with the specified text to be displayed on the bar. More...
 
 QgsMessageBarItem (const QString &title, const QString &text, QWidget *widget, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=0, QWidget *parent=nullptr)
 Constructor for QgsMessageBarItem, containing a title, message with the specified text, and a custom widget to be displayed on the bar. More...
 
 QgsMessageBarItem (QWidget *widget, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=0, QWidget *parent=nullptr)
 Constructor for QgsMessageBarItem, containing a custom widget to be displayed on the bar. More...
 
int duration () const
 Returns the duration (in seconds) of the message. More...
 
QString getStyleSheet ()
 Returns the styleSheet which should be used to style a QgsMessageBar object when this item is displayed. More...
 
QIcon icon () const
 Returns the icon for the message. More...
 
Qgis::MessageLevel level () const
 Returns the message level for the message. More...
 
QgsMessageBarItemsetDuration (int duration)
 Sets the duration (in seconds) to show the message for. More...
 
QgsMessageBarItemsetIcon (const QIcon &icon)
 Sets the icon associated with the message. More...
 
QgsMessageBarItemsetLevel (Qgis::MessageLevel level)
 Sets the message level for the item, which controls how the message bar is styled when the item is displayed. More...
 
QgsMessageBarItemsetText (const QString &text)
 Sets the message text to show in the item. More...
 
QgsMessageBarItemsetTitle (const QString &title)
 Sets the title for in the item. More...
 
QgsMessageBarItemsetWidget (QWidget *widget)
 Sets a custom widget to show in the item. More...
 
QString text () const
 Returns the text for the message. More...
 
QString title () const
 Returns the title for the message. More...
 
QWidget * widget () const
 Returns the widget for the message. More...
 

Friends

class QgsMessageBar
 

Detailed Description

Represents an item shown within a QgsMessageBar widget.

QgsMessageBarItem represents a single item (or message) which can be shown in a QgsMessageBar widget.

Definition at line 38 of file qgsmessagebaritem.h.

Constructor & Destructor Documentation

◆ QgsMessageBarItem() [1/4]

QgsMessageBarItem::QgsMessageBarItem ( const QString &  text,
Qgis::MessageLevel  level = Qgis::MessageLevel::Info,
int  duration = 0,
QWidget *  parent = nullptr 
)

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.

Definition at line 29 of file qgsmessagebaritem.cpp.

◆ QgsMessageBarItem() [2/4]

QgsMessageBarItem::QgsMessageBarItem ( const QString &  title,
const QString &  text,
Qgis::MessageLevel  level = Qgis::MessageLevel::Info,
int  duration = 0,
QWidget *  parent = nullptr 
)

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.

Definition at line 38 of file qgsmessagebaritem.cpp.

◆ QgsMessageBarItem() [3/4]

QgsMessageBarItem::QgsMessageBarItem ( const QString &  title,
const QString &  text,
QWidget *  widget,
Qgis::MessageLevel  level = Qgis::MessageLevel::Info,
int  duration = 0,
QWidget *  parent = nullptr 
)

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.

Definition at line 48 of file qgsmessagebaritem.cpp.

◆ QgsMessageBarItem() [4/4]

QgsMessageBarItem::QgsMessageBarItem ( QWidget *  widget,
Qgis::MessageLevel  level = Qgis::MessageLevel::Info,
int  duration = 0,
QWidget *  parent = nullptr 
)

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.

Definition at line 61 of file qgsmessagebaritem.cpp.

Member Function Documentation

◆ dismiss

void QgsMessageBarItem::dismiss ( )
slot

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.

Since
QGIS 3.4

Definition at line 280 of file qgsmessagebaritem.cpp.

◆ duration()

int QgsMessageBarItem::duration ( ) const
inline

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()

Definition at line 179 of file qgsmessagebaritem.h.

◆ getStyleSheet()

QString QgsMessageBarItem::getStyleSheet ( )
inline

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

Definition at line 185 of file qgsmessagebaritem.h.

◆ icon()

QIcon QgsMessageBarItem::icon ( ) const

Returns the icon for the message.

See also
setIcon()

Definition at line 268 of file qgsmessagebaritem.cpp.

◆ level()

Qgis::MessageLevel QgsMessageBarItem::level ( ) const

Returns the message level for the message.

See also
setLevel()

Definition at line 236 of file qgsmessagebaritem.cpp.

◆ setDuration()

QgsMessageBarItem * QgsMessageBarItem::setDuration ( int  duration)

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()

Definition at line 274 of file qgsmessagebaritem.cpp.

◆ setIcon()

QgsMessageBarItem * QgsMessageBarItem::setIcon ( const QIcon &  icon)

Sets the icon associated with the message.

See also
icon()

Definition at line 262 of file qgsmessagebaritem.cpp.

◆ setLevel()

QgsMessageBarItem * QgsMessageBarItem::setLevel ( Qgis::MessageLevel  level)

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

See also
level()

Definition at line 224 of file qgsmessagebaritem.cpp.

◆ setText()

QgsMessageBarItem * QgsMessageBarItem::setText ( const QString &  text)

Sets the message text to show in the item.

See also
text()

Definition at line 200 of file qgsmessagebaritem.cpp.

◆ setTitle()

QgsMessageBarItem * QgsMessageBarItem::setTitle ( const QString &  title)

Sets the title for in the item.

See also
title()

Definition at line 212 of file qgsmessagebaritem.cpp.

◆ setWidget()

QgsMessageBarItem * QgsMessageBarItem::setWidget ( QWidget *  widget)

Sets a custom widget to show in the item.

See also
widget()

Definition at line 241 of file qgsmessagebaritem.cpp.

◆ styleChanged

void QgsMessageBarItem::styleChanged ( const QString &  styleSheet)
signal

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

◆ text()

QString QgsMessageBarItem::text ( ) const

Returns the text for the message.

See also
setText()

Definition at line 207 of file qgsmessagebaritem.cpp.

◆ title()

QString QgsMessageBarItem::title ( ) const

Returns the title for the message.

See also
setTitle()

Definition at line 219 of file qgsmessagebaritem.cpp.

◆ widget()

QWidget * QgsMessageBarItem::widget ( ) const

Returns the widget for the message.

See also
setWidget()

Definition at line 257 of file qgsmessagebaritem.cpp.

Friends And Related Function Documentation

◆ QgsMessageBar

friend class QgsMessageBar
friend

Definition at line 225 of file qgsmessagebaritem.h.


The documentation for this class was generated from the following files: