Workspace 6.21.5
Public Slots | Signals | Public Member Functions | Static Public Member Functions | List of all members
QtDebugCapture Class Reference

Captures Qt debug messages. More...

#include <Workspace/Application/qtdebugcapture.h>

Inherits QObject.

Public Slots

void pushMessage (const QString &msg)
 

Signals

void newMessage ()
 

Public Member Functions

void destroyInstance ()
 
bool isBlockingIncomingMessages () const
 
QStringList popMessages ()
 
void setBlockIncomingMessages (bool b)
 

Static Public Member Functions

static QtDebugCapturegetInstance ()
 

Detailed Description

newMessage() is emitted whenever a new Qt debug message is recieved. Clients can get and clear the current messages by calling popMessages() which returns all messages as individual elements of a QStringList.

Note: Using this class will install a qInstallMsgHandler but the custom handler installed still forwards messages to stderr (as done by the default handler) in addition to making copies available via popMessages().

Typically usage:

main() { QApplication a(argc, argv); QtDebugCapture::getInstance(); // activate the QtDebugCapture before doing anything

.. program startup and widget creation ..

// This call will now return any messages captured during startup - you could now display them // in a QTextEdit that is part of your UI or output them to a log file. QtDebugCapture::getInstance.popMessages()

// Make signal slot connection for any further messages connect(&QtDebugCapture::getInstance(), SIGNAL(newMessage()), mainWindow, SLOT(handleNewQtMessage());

... }

Member Function Documentation

◆ destroyInstance()

void destroyInstance ( )

◆ getInstance()

QtDebugCapture & getInstance ( )
static

◆ isBlockingIncomingMessages()

bool isBlockingIncomingMessages ( ) const
Returns
whether or not incoming messages are being blocked.
See also
setBlockIncomingMessages

◆ newMessage

void newMessage ( )
signal

◆ popMessages()

QStringList popMessages ( )

◆ pushMessage

void pushMessage ( const QString &  msg)
slot

◆ setBlockIncomingMessages()

void setBlockIncomingMessages ( bool  b)
Parameters
bSet whether or not to block incoming messages.

When enabled, incoming messages will not be received, nor will they be forwarded to stderr.