A self-scaling widget that displays messages as separate instances of QLabel. More...
#include <importantmessageswidget.h>
Public Slots | |
void | addMessage (const QString &message) |
Adds a new message without a timestamp. More... | |
void | addMessage (const QString &message, const QDateTime &dateTime) |
Adds a message with a timestamp. More... | |
void | addMessage (const QString &message, unsigned timestamp) |
Adds a message with a timestamp. More... | |
void | clear () |
Clears all messages from the widghet. More... | |
void | removeOldest (int num) |
Removes a number of oldest messages from the widget. More... | |
void | removeOneOldest () |
Will remove one oldest message. More... | |
Public Member Functions | |
ImportantMessagesWidget (QWidget *pParent=nullptr) | |
unsigned | maxMessages () const |
Amount of messages that can be displayed in the widget at the same time. More... | |
void | setMaxMessages (unsigned num) |
A self-scaling widget that displays messages as separate instances of QLabel.
This widget adds new messages by wrapping them in a QLabel widgets and inserting those widgets into a vertical layout. Number of QLabel widgets is limited by _maxMessages field. Old messages will be removed once their time of life exceeds MAX_MSG_KEEP_TIME_SEC . Widget will auto-hide and auto-show
Definition at line 44 of file importantmessageswidget.h.
|
slot |
Adds a new message without a timestamp.
Definition at line 68 of file importantmessageswidget.cpp.
|
slot |
Adds a message with a timestamp.
message | Message to add. |
timestamp | QDateTime object representing time. |
Definition at line 73 of file importantmessageswidget.cpp.
|
slot |
Adds a message with a timestamp.
message | Message to add. |
timestamp | Time in seconds since the epoch. |
Definition at line 98 of file importantmessageswidget.cpp.
|
slot |
Clears all messages from the widghet.
Widget will shrink itself in a way that will make it invisible.
Definition at line 103 of file importantmessageswidget.cpp.
unsigned ImportantMessagesWidget::maxMessages | ( | ) | const |
Amount of messages that can be displayed in the widget at the same time.
Definition at line 154 of file importantmessageswidget.cpp.
|
slot |
Removes a number of oldest messages from the widget.
Widget will shrink with each message removed.
num | Amount of messages to remove. If higher than the actual count of messages, will work the same as clear(). |
Definition at line 129 of file importantmessageswidget.cpp.
|
slot |
Will remove one oldest message.
Definition at line 140 of file importantmessageswidget.cpp.