Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDebug() does not display anything.

QDebug() does not display anything.

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 24.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    u2gilles
    wrote on last edited by
    #1

    Hi All,

    I am new on Qt. This question should be basic for most of you but i have no choice to bother you after searching the solution for 1 day. Basically, qDebug() won’t display anything when i create a QCoreApplication is the main() This main.ccp won’t display “test qdebug” :
    #include <QtCore/QCoreApplication>
    #include <QDebug>
    int main(int argc, char *argv[]) {
    QCoreApplication a(argc, argv);
    qDebug() << “test qdebug\n”;
    return a.exec();
    }

    Whereas this main.ccp displays “test qdebug” :
    #include <QtCore/QCoreApplication>
    #include <QDebug>
    int main(int argc, char *argv[]) {
    qDebug() << “test qdebug\n”;
    }

    Here in my .pro :
    QT += core
    QT -= gui
    TARGET = test13
    CONFIG += console
    CONFIG -= app_bundle
    TEMPLATE = app
    SOURCES += main.cpp

    I also tried to ask CONFIG += debug but it still not work
    I also tried to use qDebug() in the constructor of a class, still not working.
    I am created this simple project on Qt Creator (Console Application)
    I am using GCC 4.4 – GT 4.8.1

    After reading hours about .pro file, moc, QDebug, I really have no clue why I can’t have qDebug() work.
    Thanks in advance for your help

    Gilles

    Paris

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Hi, please enclose your code in '@' tags, and format nicely, currently it's hard to read it.

      (Z(:^

      1 Reply Last reply
      0
      • U Offline
        U Offline
        u2gilles
        wrote on last edited by
        #3

        Below is the code with '@' tags.
        I also would like to add that when i download a working example from the net, qDebug() does not work too. So i am pretty sure my issue is related to my desktop/Qt configuration , not to my code.

        I am new on Qt. This question should be basic for most of you but i have no choice to bother you after searching the solution for 1 day. Basically, qDebug() won’t display anything when i create a QCoreApplication is the main()
        This main.ccp won’t display “test qdebug” :
        @#include <QtCore/QCoreApplication>
        #include <QDebug>
        int main(int argc, char *argv[]) {
        QCoreApplication a(argc, argv);
        qDebug() << “test qdebug\n”;
        return a.exec();
        }@

        Whereas this main.ccp displays “test qdebug” :
        @#include <QtCore/QCoreApplication>
        #include <QDebug>
        int main(int argc, char *argv[]) {
        qDebug() << “test qdebug\n”;
        }@

        Here in my .pro :
        @QT += core
        QT -= gui
        TARGET = test13
        CONFIG += console
        CONFIG -= app_bundle
        TEMPLATE = app
        SOURCES += main.cpp@

        I also tried to ask CONFIG += debug but it still not work
        I also tried to use qDebug() in the constructor of a class, still not working.
        I am created this simple project on Qt Creator (Console Application)
        I am using GCC 4.4 – GT 4.8.1

        After reading hours about .pro file, moc, QDebug, I really have no clue why I can’t have qDebug() work.
        Thanks in advance for your help

        Gilles

        Paris

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Hm. Try if printf works. I remember I had similar problem once, but I can't remember how I solved it, sadly.

          PS. No need to add endline - QDebug does that automatically for you.

          (Z(:^

          1 Reply Last reply
          0
          • B Offline
            B Offline
            broadpeak
            wrote on last edited by
            #5

            Hm. Your code is works perfectly in my pc:

            (Probably you have problem with the quotation mark(s)
            Pay attention when you copy-paste some code into your QtCreator, because the copied quotation mark can be wrong)

            main.cpp
            @
            #include <QtCore/QCoreApplication>
            #include <QDebug>

            int main(int argc, char *argv[])
            {
            qDebug() << "test qdebug\n";
            }
            @

            .pro file

            @
            QT += core
            QT -= gui
            TARGET = test13
            CONFIG += console
            CONFIG -= app_bundle
            TEMPLATE = app
            SOURCES += main.cpp
            @

            1 Reply Last reply
            0
            • JeroentjehomeJ Offline
              JeroentjehomeJ Offline
              Jeroentjehome
              wrote on last edited by
              #6

              Hi there,

              Hmm, maybe just easy to ask, but did you check out the little checkbox in the project folder that says run in console mode?
              Because that is where the debug will then be put. Otherwise, if you lease the CONFIG += console out it will come in your application output.
              Both should work with your code.

              greetz

              Greetz, Jeroen

              1 Reply Last reply
              0
              • U Offline
                U Offline
                u2gilles
                wrote on last edited by
                #7

                sierdzio,
                I can't even display printf or cout. The following code does not diplay anything :
                @#include <QtCore/QCoreApplication>
                #include <QDebug>
                #include <stdio.h>
                #include <iostream>

                int main(int argc, char *argv[]) {
                QCoreApplication a(argc, argv);
                qDebug() << "test qdebug";
                printf("test printf");
                std::cout << "test std::cout\n";
                return a.exec();
                }@

                and the following code display everything :
                @#include <QtCore/QCoreApplication>
                #include <QDebug>
                #include <stdio.h>
                #include <iostream>

                int main(int argc, char *argv[]) {
                // QCoreApplication a(argc, argv);
                qDebug() << "test qdebug";
                printf("test printf");
                std::cout << "test std::cout\n";
                // return a.exec();
                }@

                greetz,
                In my Qt creator 2.4.1. I can't see any little checkbox for console mode. What i did is to choose debug in the "qmake build configuration" popup menu.

                My quotation mark(s) looks good. If it not the case, i could not even compile.

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  Seems that the core application is to blame here, but that seems insane. Try running from terminal instead of Qt Creator. Maybe Creator connects to cerr only? Weird.

                  (Z(:^

                  1 Reply Last reply
                  0
                  • U Offline
                    U Offline
                    u2gilles
                    wrote on last edited by
                    #9

                    My problem is fixed.
                    In my c:\windows directory I had all Qt DLL (QtCore4.dll ....) coming from a previous Qt installation i did a few years ago. I don't remember well but i may have put them there manually. And that was the dlls my code was dynamically linked to (maybe because c:\windows appears first in PATH).
                    After removing those dll from c:\windows, my problem disappeared. The up to date DLL from C:\dev\Qt\Desktop\Qt\4.8.1\mingw\bin are now used.

                    Thanks a lot Guys. I appreciated your help.

                    1 Reply Last reply
                    0
                    • sierdzioS Offline
                      sierdzioS Offline
                      sierdzio
                      Moderators
                      wrote on last edited by
                      #10

                      wow, that is quite unexpected :) Glad you are OK again, though :D

                      (Z(:^

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved