QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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.
 

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.
 

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.
 
 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.
 
 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.
 
 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.
 
int duration () const
 Returns the duration (in seconds) of the message.
 
QString getStyleSheet ()
 Returns the styleSheet which should be used to style a QgsMessageBar object when this item is displayed.
 
QIcon icon () const
 Returns the icon for the message.
 
Qgis::MessageLevel level () const
 Returns the message level for the message.
 
QgsMessageBarItemsetDuration (int duration)
 Sets the duration (in seconds) to show the message for.
 
QgsMessageBarItemsetIcon (const QIcon &icon)
 Sets the icon associated with the message.
 
QgsMessageBarItemsetLevel (Qgis::MessageLevel level)
 Sets the message level for the item, which controls how the message bar is styled when the item is displayed.
 
QgsMessageBarItemsetText (const QString &text)
 Sets the message text to show in the item.
 
QgsMessageBarItemsetTitle (const QString &title)
 Sets the title for in the item.
 
QgsMessageBarItemsetWidget (QWidget *widget)
 Sets a custom widget to show in the item.
 
QString text () const
 Returns the text for the message.
 
QString title () const
 Returns the title for the message.
 
QWidget * widget () const
 Returns the widget for the message.
 

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 30 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 39 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 49 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 62 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 281 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 178 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 184 of file qgsmessagebaritem.h.

◆ icon()

QIcon QgsMessageBarItem::icon ( ) const

Returns the icon for the message.

See also
setIcon()

Definition at line 269 of file qgsmessagebaritem.cpp.

◆ level()

Qgis::MessageLevel QgsMessageBarItem::level ( ) const

Returns the message level for the message.

See also
setLevel()

Definition at line 237 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 275 of file qgsmessagebaritem.cpp.

◆ setIcon()

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

Sets the icon associated with the message.

See also
icon()

Definition at line 263 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 225 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 201 of file qgsmessagebaritem.cpp.

◆ setTitle()

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

Sets the title for in the item.

See also
title()

Definition at line 213 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 242 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 208 of file qgsmessagebaritem.cpp.

◆ title()

QString QgsMessageBarItem::title ( ) const

Returns the title for the message.

See also
setTitle()

Definition at line 220 of file qgsmessagebaritem.cpp.

◆ widget()

QWidget * QgsMessageBarItem::widget ( ) const

Returns the widget for the message.

See also
setWidget()

Definition at line 258 of file qgsmessagebaritem.cpp.

Friends And Related Symbol Documentation

◆ QgsMessageBar

friend class QgsMessageBar
friend

Definition at line 224 of file qgsmessagebaritem.h.


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