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

  • SEARCH
  • Home
  • 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 8086129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:21:22+00:00 2026-06-05T18:21:22+00:00

I am adding unit tests to project in Qt and am looking to use

  • 0

I am adding unit tests to project in Qt and am looking to use QTestLib. I have set up the tests and they are running fine.

The issue is that in the project we have overridden qDebug() to output to our own log file. This works great when running the app, the problem is that when I am testing the classes, it will sometimes start logging, which is then sent to the output window. The result is a complete disaster that is next to impossible to read as our logs get mixed in with the QTest output.

I am wondering if there is a way to suppress the qDebug() output, or at least move it somewhere else. I have tried adding #define QT_NO_DEBUG_OUTPUT and also using qInstallMsgHandler(messageOutput); to redirect or prevent the output, but neither had any effect.

  • 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-06-05T18:21:23+00:00Added an answer on June 5, 2026 at 6:21 pm
    1. The QT_NO_DEBUG_OUTPUT define must go into your project files or makefiles and must be present for every file you compile. You must then recompile your application (not Qt itself of course). This macro’s presence on compiler’s command line guarantees that the first time QDebug header is included by any code, the qDebug will be redefined to a no-op. That’s what this macro does: it disables qDebug if it is present when the <QtCore/qdebug.h> header gets included — whether directly by you or indirectly by other headers.

    2. Using qInstallMsgHandler certainly works at suppressing debug output.

    Below is a self-contained example.

    #if 0
    // Enabling this section disables all debug output from non-Qt code.
    #define QT_NO_DEBUG_OUTPUT
    #endif
    #include <QtCore/QDebug>
    
    void noMessageOutput(QtMsgType, const char *)
    {}
    
    int main(int argc, char *argv[])
    {
        qDebug() << "I'm shown";
        qInstallMsgHandler(noMessageOutput);
        qDebug() << "I'm hidden";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking into adding unit tests at work. I used MbUnit in the
I'm looking into adding some unit tests for some classes in my data access
I'm strongly considering adding unit testing to an existing project that is in production.
I'm trying to implement unit tests in my current project. After that I'll start
I've been following this blog post: Adding unit tests to existing project. I'm getting
I'm adding unit tests (SenTest) to my existing XCode 4.2 project. XCode is complaining
Today I started adding unit tests to an ASP.NET MVC project we are developing
I'm having some issues running my unit tests when my pom is set to
I've been adding unit tests to some legacy C++ code, and I've run into
Open Source projects that ship with unit tests based on NUnit also usually ship

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.