Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6739551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:30:08+00:00 2026-05-26T11:30:08+00:00

Header: #define TRACE_ERROR(s) \ { … char TraceBuffer[512]; sprintf(TraceBuffer, %s\t(%s:%d), s, __FILE__, __LINE__); DebugErrTrace(TraceBuffer);

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:30:09+00:00Added an answer on May 26, 2026 at 11:30 am

    According to Qt Creator source code (there), the hyperlinks are only created for lines matching these regular expressions:

    "^(?:\\[Qt Message\\] )?(file:///.+:\\d+(?::\\d+)?):"
    "Object::.*in (.*:\\d+)"
    "ASSERT: .* in file (.+, line \\d+)"
    "^   Loc: \\[(.*)\\]"
    

    So the simplest lines you could construct look like this:

    qWarning("file:///%s:%i: %s", __FILE__, __LINE__, "your message");
    qWarning("   Loc: [%s:%i] %s", __FILE__, __LINE__, "your message");
    

    Qt Creator doesn’t seem to care if the path after "file:///" is absolute or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Non inline function defined in header file with guards #if !defined(HEADER_RANDOM_H) #define HEADER_RANDOM_H void
I'd like to define a constant char* in my header file for my .cpp
Suppose I have #define foo in various header files. It may expand to some
If I define a non-member function in a header, will it always be inlined
In a pre-compiled header if I do: #define DS_BUILD #define PGE_BUILD #define DEMO then
I have a header file with all the enums listed (#ifndef #define #endif construct
I have a header file like this: #ifndef __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #define __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #ifdef _DEBUG //
Suppose I have a list of #define s in a header file for an
I have C++ project (VS2005) which includes header file with version number in #define
I have this class header //header for class. #ifndef Container_H #define Container_H #include <iostream>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.