Important: Please read the Qt Code of Conduct -

Why Does qDebug() Produce no Output?

  • I've recently started to learn QT, by following a tutorial writing my own project and source files (not using QtCreator or Designer). I'd like to use qDebug(), but I haven't been able to get any output from any useful area of my code. I found one similar complaint in your forum: QDebug() does not display anything, but the resolution to that problem does not seem applicable to my situation. My Qt5 system was installed from the Fedora 23 repos. My initial source code was much more complicated, but I've managed to pare down the code to the following which illustrates the problem:

    int main(int argc, char *argv[]) {
      qDebug("From qDebug before app");
      printf("From printf before app\n");
      fprintf(stderr,"From fprintf(stderr) before app\n");
      QApplication app(argc, argv); 
      qDebug("From qDebug after app");
      printf("From printf after app\n");
      fprintf(stderr,"From fprintf(stderr) after app\n");
      return app.exec();

    The output from the above code:

    From qDebug before app
    From printf before app
    From fprintf(stderr) before app
    From printf after app
    From fprintf(stderr) after app

    The basic question is, why does the first qDebug() call generate output while the second one doesn't? Obviously, something is happening in the QApplication constructor which changes qDebug's behavior. Can this be anything but a bug??
    I've tried a great many combinations in my actual code; I never get any output except from a call (if present) before QApplication. I've also tried the qDebug() << "message" syntax: this fails as well. I've tried qInstallMessageHandler(0) with no effect.

Log in to reply