QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
#include <qgsmessagebar.h>
Public Slots | |
bool | clearWidgets () |
Removes all items from the bar. More... | |
bool | popWidget () |
Remove the currently displayed item from the bar and display the next item in the stack. More... | |
void | pushCritical (const QString &title, const QString &message) |
Pushes a critical warning message 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 message with default timeout to the message bar. More... | |
Signals | |
void | widgetAdded (QgsMessageBarItem *item) |
Emitted whenever an item is added to the bar. More... | |
void | widgetRemoved (QgsMessageBarItem *item) |
Emitted whenever an item was removed from the bar. More... | |
Public Member Functions | |
QgsMessageBar (QWidget *parent=nullptr) | |
Constructor for QgsMessageBar. More... | |
QgsMessageBarItem * | currentItem () |
Returns the current visible item, or nullptr if no item is shown. More... | |
QList< QgsMessageBarItem * > | items () |
Returns a list of all items currently visible or queued for the bar. More... | |
bool | popWidget (QgsMessageBarItem *item) |
Remove the specified item from the bar, and display the next most recent one in the stack. 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, Qgis::MessageLevel level=Qgis::Info, int duration=5) |
A convenience method for pushing a message with the specified text to the bar. More... | |
void | pushMessage (const QString &title, const QString &text, const QString &showMore, Qgis::MessageLevel level=Qgis::Info, int duration=5) |
A convenience method for pushing a message with the specified title and text to the bar. More... | |
void | pushMessage (const QString &title, const QString &text, Qgis::MessageLevel level=Qgis::Info, int duration=5) |
A convenience method for pushing a message with the specified title and text to the bar. More... | |
QgsMessageBarItem * | pushWidget (QWidget *widget, Qgis::MessageLevel level=Qgis::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 QgsMessageBarItem * | createMessage (const QString &text, QWidget *parent=nullptr) |
Creates message bar item widget containing a message text to be displayed on the bar. More... | |
static QgsMessageBarItem * | createMessage (const QString &title, const QString &text, QWidget *parent=nullptr) |
Creates message bar item widget containing a title and message text to be displayed on the bar. More... | |
static QgsMessageBarItem * | createMessage (QWidget *widget, QWidget *parent=nullptr) |
Creates message bar item widget containing a custom widget to be displayed on the bar. More... | |
Protected Member Functions | |
void | mousePressEvent (QMouseEvent *e) override |
Friends | |
class | TestQgsMessageBar |
A bar for displaying non-blocking messages to the user.
QgsMessageBar is a reusable widget which allows for providing feedback to users in a non-intrusive way. Messages are shown in a horizontal bar widget, which is styled automatically to reflect the severity ("message level") of the displayed message (e.g. warning messages are styled in an orange color scheme, critical errors are shown in red, etc).
The message bar supports automatic stacking of multiple messages, so that only the most recent message is shown to users. Users can then manually dismiss individual messages to remove them from the stack, causing the next-most-recent message to be shown. If no messages are available to show then the message bar automatically hides.
The class also supports pushing custom widgets to the notification stack via the pushWidget() method.
Definition at line 60 of file qgsmessagebar.h.
QgsMessageBar::QgsMessageBar | ( | QWidget * | parent = nullptr | ) |
Constructor for QgsMessageBar.
Definition at line 35 of file qgsmessagebar.cpp.
|
slot |
Removes all items from the bar.
true
if all items were removed, false
otherwise Definition at line 181 of file qgsmessagebar.cpp.
|
static |
Creates message bar item widget containing a message text to be displayed on the bar.
The caller takes ownership of the returned item.
Definition at line 363 of file qgsmessagebar.cpp.
|
static |
Creates message bar item widget containing a title and message text to be displayed on the bar.
The caller takes ownership of the returned item.
Definition at line 369 of file qgsmessagebar.cpp.
|
static |
Creates message bar item widget containing a custom widget to be displayed on the bar.
The caller takes ownership of the returned item.
Definition at line 374 of file qgsmessagebar.cpp.
QgsMessageBarItem * QgsMessageBar::currentItem | ( | ) |
Returns the current visible item, or nullptr
if no item is shown.
Definition at line 353 of file qgsmessagebar.cpp.
QList< QgsMessageBarItem * > QgsMessageBar::items | ( | ) |
Returns a list of all items currently visible or queued for the bar.
Definition at line 358 of file qgsmessagebar.cpp.
|
overrideprotected |
Definition at line 110 of file qgsmessagebar.cpp.
|
slot |
Remove the currently displayed item from the bar and display the next item in the stack.
If no remaining items are present, the bar will be hidden.
true
if the widget was removed, false
otherwise Definition at line 169 of file qgsmessagebar.cpp.
bool QgsMessageBar::popWidget | ( | QgsMessageBarItem * | item | ) |
Remove the specified item from the bar, and display the next most recent one in the stack.
If no messages remain in the stack, then the bar will be hidden.
item | previously added item to remove. |
true
if item was removed, false
otherwise Definition at line 160 of file qgsmessagebar.cpp.
|
slot |
Pushes a critical warning message with default timeout to the message bar.
title | title string for message |
message | The message to be displayed |
Definition at line 209 of file qgsmessagebar.cpp.
|
slot |
Pushes a information message with default timeout to the message bar.
title | title string for message |
message | The message to be displayed |
Definition at line 199 of file qgsmessagebar.cpp.
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 item.
Definition at line 274 of file qgsmessagebar.cpp.
void QgsMessageBar::pushMessage | ( | const QString & | text, |
Qgis::MessageLevel | level = Qgis::Info , |
||
int | duration = 5 |
||
) |
A convenience method for pushing a message with the specified text to the bar.
The level argument specifies the desired message level (severity) of the message, which controls how the message bar is styled.
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.
Definition at line 379 of file qgsmessagebar.cpp.
void QgsMessageBar::pushMessage | ( | const QString & | title, |
const QString & | text, | ||
const QString & | showMore, | ||
Qgis::MessageLevel | level = Qgis::Info , |
||
int | duration = 5 |
||
) |
A convenience method for pushing a message with the specified title and text to the bar.
Additional message content specified via showMore will be shown when the user presses a "more" button.
The level argument specifies the desired message level (severity) of the message, which controls how the message bar is styled.
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.
Definition at line 327 of file qgsmessagebar.cpp.
void QgsMessageBar::pushMessage | ( | const QString & | title, |
const QString & | text, | ||
Qgis::MessageLevel | level = Qgis::Info , |
||
int | duration = 5 |
||
) |
A convenience method for pushing a message with the specified title and text to the bar.
The level argument specifies the desired message level (severity) of the message, which controls how the message bar is styled.
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.
Definition at line 314 of file qgsmessagebar.cpp.
|
slot |
Pushes a success message with default timeout to the message bar.
title | title string for message |
message | The message to be displayed |
Definition at line 194 of file qgsmessagebar.cpp.
|
slot |
Pushes a warning message with default timeout to the message bar.
title | title string for message |
message | The message to be displayed |
Definition at line 204 of file qgsmessagebar.cpp.
QgsMessageBarItem * QgsMessageBar::pushWidget | ( | QWidget * | widget, |
Qgis::MessageLevel | level = Qgis::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.
widget | message widget to display |
level | is Qgis::Info, Warning, Critical or Success |
duration | timeout duration of message in seconds, 0 value indicates no timeout (i.e. the message must be manually cleared by the user). |
Definition at line 298 of file qgsmessagebar.cpp.
|
signal |
Emitted whenever an item is added to the bar.
|
signal |
Emitted whenever an item was removed from the bar.
|
friend |
Definition at line 272 of file qgsmessagebar.h.