QGIS API Documentation  2.99.0-Master (90ae728)
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QgsMessageBar Class Reference

A bar for displaying non-blocking messages to the user. More...

#include <qgsmessagebar.h>

Inheritance diagram for QgsMessageBar:
Inheritance graph
[legend]

Public Types

enum  MessageLevel { INFO = 0, WARNING = 1, CRITICAL = 2, SUCCESS = 3 }
 

Public Slots

bool clearWidgets ()
 Remove all items from the bar's widget list. More...
 
bool popWidget ()
 Remove the currently displayed widget from the bar and display the next in the stack if any or hide the bar. More...
 
void pushCritical (const QString &title, const QString &message)
 Pushes a critical warning with default timeout to the message bar. More...
 
void pushInfo (const QString &title, const QString &message)
 Pushes a information message with default timeout to the message bar. More...
 
void pushSuccess (const QString &title, const QString &message)
 Pushes a success message with default timeout to the message bar. More...
 
void pushWarning (const QString &title, const QString &message)
 Pushes a warning with default timeout to the message bar. More...
 

Signals

void widgetAdded (QgsMessageBarItem *item)
 emitted when a message widget is added to the bar More...
 
void widgetRemoved (QgsMessageBarItem *item)
 emitted when a message widget was removed from the bar More...
 

Public Member Functions

 QgsMessageBar (QWidget *parent=nullptr)
 
QgsMessageBarItemcurrentItem ()
 
bool popWidget (QgsMessageBarItem *item)
 Remove the passed widget from the bar (if previously added), then display the next one in the stack if any or hide the bar. More...
 
void pushItem (QgsMessageBarItem *item)
 Display a message item on the bar after hiding the currently visible one and putting it in a stack. More...
 
void pushMessage (const QString &text, MessageLevel level=INFO, int duration=5)
 convenience method for pushing a message to the bar More...
 
void pushMessage (const QString &title, const QString &text, MessageLevel level=INFO, int duration=5)
 convenience method for pushing a message with title to the bar More...
 
QgsMessageBarItempushWidget (QWidget *widget, MessageLevel level=INFO, int duration=0)
 Display a widget as a message on the bar after hiding the currently visible one and putting it in a stack. More...
 

Static Public Member Functions

static QgsMessageBarItemcreateMessage (const QString &text, QWidget *parent=nullptr)
 make out a widget containing a message to be displayed on the bar More...
 
static QgsMessageBarItemcreateMessage (const QString &title, const QString &text, QWidget *parent=nullptr)
 make out a widget containing title and message to be displayed on the bar More...
 
static QgsMessageBarItemcreateMessage (QWidget *widget, QWidget *parent=nullptr)
 make out a widget containing title and message to be displayed on the bar More...
 

Protected Member Functions

void mousePressEvent (QMouseEvent *e) override
 

Detailed Description

A bar for displaying non-blocking messages to the user.

Definition at line 43 of file qgsmessagebar.h.

Member Enumeration Documentation

◆ MessageLevel

Enumerator
INFO 
WARNING 
CRITICAL 
SUCCESS 

Definition at line 48 of file qgsmessagebar.h.

Constructor & Destructor Documentation

◆ QgsMessageBar()

QgsMessageBar::QgsMessageBar ( QWidget *  parent = nullptr)

Definition at line 33 of file qgsmessagebar.cpp.

Member Function Documentation

◆ clearWidgets

bool QgsMessageBar::clearWidgets ( )
slot

Remove all items from the bar's widget list.

Returns
true if all items were removed, false otherwise

Definition at line 192 of file qgsmessagebar.cpp.

◆ createMessage() [1/3]

QgsMessageBarItem * QgsMessageBar::createMessage ( const QString &  text,
QWidget *  parent = nullptr 
)
static

make out a widget containing a message to be displayed on the bar

Definition at line 295 of file qgsmessagebar.cpp.

◆ createMessage() [2/3]

QgsMessageBarItem * QgsMessageBar::createMessage ( const QString &  title,
const QString &  text,
QWidget *  parent = nullptr 
)
static

make out a widget containing title and message to be displayed on the bar

Definition at line 301 of file qgsmessagebar.cpp.

◆ createMessage() [3/3]

QgsMessageBarItem * QgsMessageBar::createMessage ( QWidget *  widget,
QWidget *  parent = nullptr 
)
static

make out a widget containing title and message to be displayed on the bar

Definition at line 306 of file qgsmessagebar.cpp.

◆ currentItem()

QgsMessageBarItem* QgsMessageBar::currentItem ( )
inline

Definition at line 94 of file qgsmessagebar.h.

◆ mousePressEvent()

void QgsMessageBar::mousePressEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 102 of file qgsmessagebar.cpp.

◆ popWidget() [1/2]

bool QgsMessageBar::popWidget ( QgsMessageBarItem item)

Remove the passed widget from the bar (if previously added), then display the next one in the stack if any or hide the bar.

Parameters
itemitem to remove
Returns
true if the widget was removed, false otherwise

Definition at line 155 of file qgsmessagebar.cpp.

◆ popWidget [2/2]

bool QgsMessageBar::popWidget ( )
slot

Remove the currently displayed widget from the bar and display the next in the stack if any or hide the bar.

Returns
true if the widget was removed, false otherwise

Definition at line 179 of file qgsmessagebar.cpp.

◆ pushCritical

void QgsMessageBar::pushCritical ( const QString &  title,
const QString &  message 
)
slot

Pushes a critical warning with default timeout to the message bar.

Parameters
titletitle string for message
messageThe message to be displayed
Note
added in 2.8

Definition at line 221 of file qgsmessagebar.cpp.

◆ pushInfo

void QgsMessageBar::pushInfo ( const QString &  title,
const QString &  message 
)
slot

Pushes a information message with default timeout to the message bar.

Parameters
titletitle string for message
messageThe message to be displayed
Note
added in 2.8

Definition at line 211 of file qgsmessagebar.cpp.

◆ pushItem()

void QgsMessageBar::pushItem ( QgsMessageBarItem item)

Display a message item on the bar after hiding the currently visible one and putting it in a stack.

The message bar will take ownership of the item.

Parameters
itemItem to display

Definition at line 265 of file qgsmessagebar.cpp.

◆ pushMessage() [1/2]

void QgsMessageBar::pushMessage ( const QString &  text,
MessageLevel  level = INFO,
int  duration = 5 
)
inline

convenience method for pushing a message to the bar

Definition at line 90 of file qgsmessagebar.h.

◆ pushMessage() [2/2]

void QgsMessageBar::pushMessage ( const QString &  title,
const QString &  text,
QgsMessageBar::MessageLevel  level = INFO,
int  duration = 5 
)

convenience method for pushing a message with title to the bar

Definition at line 289 of file qgsmessagebar.cpp.

◆ pushSuccess

void QgsMessageBar::pushSuccess ( const QString &  title,
const QString &  message 
)
slot

Pushes a success message with default timeout to the message bar.

Parameters
titletitle string for message
messageThe message to be displayed
Note
added in 2.8

Definition at line 206 of file qgsmessagebar.cpp.

◆ pushWarning

void QgsMessageBar::pushWarning ( const QString &  title,
const QString &  message 
)
slot

Pushes a warning with default timeout to the message bar.

Parameters
titletitle string for message
messageThe message to be displayed
Note
added in 2.8

Definition at line 216 of file qgsmessagebar.cpp.

◆ pushWidget()

QgsMessageBarItem * QgsMessageBar::pushWidget ( QWidget *  widget,
QgsMessageBar::MessageLevel  level = INFO,
int  duration = 0 
)

Display a widget as a message on the bar after hiding the currently visible one and putting it in a stack.

Parameters
widgetmessage widget to display
levelis QgsMessageBar::INFO, WARNING, CRITICAL or SUCCESS
durationtimeout duration of message in seconds, 0 value indicates no timeout

Definition at line 273 of file qgsmessagebar.cpp.

◆ widgetAdded

void QgsMessageBar::widgetAdded ( QgsMessageBarItem item)
signal

emitted when a message widget is added to the bar

◆ widgetRemoved

void QgsMessageBar::widgetRemoved ( QgsMessageBarItem item)
signal

emitted when a message widget was removed from the bar


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