Header:
#define TRACE_ERROR(s) \
{
...
char TraceBuffer[512];
sprintf(TraceBuffer, "%s\t(%s:%d)", s, __FILE__, __LINE__);
DebugErrTrace(TraceBuffer);
...
}
Implementation:
void DebugErrTrace(char *String, ...) {
...
qDebug() << String;
}
The above spits out a line of debug trace, which might look something like
ERROR File Missing! (..\trunk\Common\FileManager.cpp:102)
in Qt Creator’s debug console.
I’ve noticed that Qt’s own error messages e.g.
Object::connect: No such slot cClass::Method(QString) in ..\trunk\Components\Class.cpp:301
create what looks like a hyperlink around the __FILE__:__LINE__ part of the debug line, linking to the line which caused the problem. Is there any way I can I do this with my own debug output?
Cheers, Sam
According to Qt Creator source code (there), the hyperlinks are only created for lines matching these regular expressions:
So the simplest lines you could construct look like this:
Qt Creator doesn’t seem to care if the path after
"file:///"is absolute or not.