QErrorMessage 類提供錯誤消息顯示對話框。 更多...
| 頭: | #include <QErrorMessage> |
| qmake: | QT += widgets |
| 繼承: | QDialog |
| QErrorMessage (QWidget * parent = nullptr) | |
| virtual | ~QErrorMessage () |
| void | showMessage (const QString & message , const QString & type ) |
| void | showMessage (const QString & message ) |
| QErrorMessage * | qtHandler () |
| virtual void | changeEvent (QEvent * e ) override |
| virtual void | done (int a ) override |
An error message widget consists of a text label and a checkbox. The checkbox lets the user control whether the same error message will be displayed again in the future, typically displaying the text, "Show this message again" translated into the appropriate local language.
For production applications, the class can be used to display messages which the user only needs to see once. To use QErrorMessage like this, you create the dialog in the usual way, and show it by calling the showMessage () slot or connecting signals to it.
靜態 qtHandler () function installs a message handler using qInstallMessageHandler () and creates a QErrorMessage that displays qDebug (), qWarning () 和 qFatal () messages. This is most useful in environments where no console is available to display warnings and error messages.
In both cases QErrorMessage will queue pending messages and display them in order, with each new message being shown as soon as the user has accepted the previous message. Once the user has specified that a message is not to be shown again it is automatically skipped, and the dialog will show the next appropriate message in the queue.
The 標準對話框 example shows how to use QErrorMessage as well as other built-in Qt dialogs.
另請參閱 QMessageBox , QStatusBar::showMessage (),和 標準對話框範例 .
Constructs and installs an error handler window with the given parent .
[slot]
void
QErrorMessage::
showMessage
(const
QString
&
message
, const
QString
&
type
)
這是重載函數。
Shows the given message, message , and returns immediately. If the user has requested for messages of type, type , not to be shown again, this function does nothing.
Normally, the message is displayed immediately. However, if there are pending messages, it will be queued to be displayed later.
該函數在 Qt 4.5 引入。
另請參閱 showMessage ().
[slot]
void
QErrorMessage::
showMessage
(const
QString
&
message
)
Shows the given message, message , and returns immediately. If the user has requested for the message not to be shown again, this function does nothing.
Normally, the message is displayed immediately. However, if there are pending messages, it will be queued to be displayed later.
[虛擬]
QErrorMessage::
~QErrorMessage
()
銷毀錯誤消息對話框。
[override virtual protected]
void
QErrorMessage::
changeEvent
(
QEvent
*
e
)
重實現: QWidget::changeEvent (QEvent *event).
[override virtual protected]
void
QErrorMessage::
done
(
int
a
)
重實現: QDialog::done (int r).
[static]
QErrorMessage
*QErrorMessage::
qtHandler
()
返迴指針指嚮 QErrorMessage object that outputs the default Qt messages. This function creates such an object, if there isn't one already.