diff options
Diffstat (limited to 'doc/src/snippets/code')
-rw-r--r-- | doc/src/snippets/code/src_corelib_global_qglobal.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/doc/src/snippets/code/src_corelib_global_qglobal.cpp b/doc/src/snippets/code/src_corelib_global_qglobal.cpp index a45a136255..21bea7aef8 100644 --- a/doc/src/snippets/code/src_corelib_global_qglobal.cpp +++ b/doc/src/snippets/code/src_corelib_global_qglobal.cpp @@ -246,27 +246,27 @@ const TInputType &myMin(const TInputType &value1, const TInputType &value2) #include <stdio.h> #include <stdlib.h> -void myMessageOutput(QtMsgType type, const char *msg) +void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const char *msg) { switch (type) { case QtDebugMsg: - fprintf(stderr, "Debug: %s\n", msg); + fprintf(stderr, "Debug: %s (%s:%u, %s)\n", msg, context.file, context.line, context.function); break; case QtWarningMsg: - fprintf(stderr, "Warning: %s\n", msg); + fprintf(stderr, "Warning: %s (%s:%u, %s)\n", msg, context.file, context.line, context.function); break; case QtCriticalMsg: - fprintf(stderr, "Critical: %s\n", msg); + fprintf(stderr, "Critical: %s (%s:%u, %s)\n", msg, context.file, context.line, context.function); break; case QtFatalMsg: - fprintf(stderr, "Fatal: %s\n", msg); + fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", msg, context.file, context.line, context.function); abort(); } } int main(int argc, char **argv) { - qInstallMsgHandler(myMessageOutput); + qInstallMessageHandler(myMessageOutput); QApplication app(argc, argv); ... return app.exec(); @@ -532,6 +532,11 @@ class MyClass : public QObject CApaApplication *myApplicationFactory(); //! [47] + +//! [49] +void myMessageHandler(QtMsgType, const QMessageLogContext &, const char *); +//! [49] + //! [qlikely] // the condition inside the "if" will be successful most of the times for (int i = 1; i <= 365; i++) { |