Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. qDebug() doesn't show messages in Qt Creator/Application Output
Forum Updated to NodeBB v4.3 + New Features

qDebug() doesn't show messages in Qt Creator/Application Output

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
14 Posts 5 Posters 118 Views 1 Watching
  • 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.
  • jronaldJ Offline
    jronaldJ Offline
    jronald
    wrote last edited by jronald
    #1

    Env

    arch linux
    KDE Plasma 6.5.3
    Qt Creator 18.0.0
    Qt 6.10.1

    Problem

    Running in debug mode, qDebug() doesn't show messages in Qt Creator/Application Output, but when running in a terminal manually, it shows.

    Codes

    #include <QDebug>
    
    int main()
    {
        qDebug() << "Test123";
        qDebug() << "Test456";
        
        return 0;
    }
    
    1 Reply Last reply
    0
    • jronaldJ jronald marked this topic as a regular topic
    • Christian EhrlicherC Christian Ehrlicher moved this topic from General and Desktop
    • jronaldJ jronald marked this topic as a question
    • jronaldJ Offline
      jronaldJ Offline
      jronald
      wrote last edited by
      #11

      It works after adding QT_ASSUME_STDERR_HAS_CONSOLE=1 in "Projects/Run Settings/Environment".
      But I don't know why.

      jronaldJ 1 Reply Last reply
      0
      • Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote last edited by
        #2

        Hi and welcome @jronald !
        please add qInfo() << QT_VERSION_STR << QT_DEBUG and post the output here.
        Cheers
        Axel

        Software Engineer
        The Qt Company, Oslo

        jronaldJ 1 Reply Last reply
        1
        • Axel SpoerlA Offline
          Axel SpoerlA Offline
          Axel Spoerl
          Moderators
          wrote last edited by Axel Spoerl
          #3

          BTW, I have the impression that main() doesn't get called at all.
          That's because of a signature mismatch, probably.
          Usually the function has this signature:

          int main(int argc, char *argv[])
          

          Software Engineer
          The Qt Company, Oslo

          aha_1980A 1 Reply Last reply
          0
          • Axel SpoerlA Axel Spoerl

            BTW, I have the impression that main() doesn't get called at all.
            That's because of a signature mismatch, probably.
            Usually the function has this signature:

            int main(int argc, char *argv[])
            
            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote last edited by
            #4

            @Axel-Spoerl In principle you are right, but I don't think thats the problem here. int main() is even the default in the C++ template in Creator and that works.

            Interesting though, what happens under the hood so the linker does not complain.

            Regards

            Qt has to stay free or it will die.

            1 Reply Last reply
            0
            • JonBJ Offline
              JonBJ Offline
              JonB
              wrote last edited by JonB
              #5

              It does not matter whether you declare main() with parameters or not. It's a C function. It gets linked/called (and caller passes parameters even if not declared as received) by its name being main(), regardless.

              1 Reply Last reply
              2
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote last edited by
                #6

                I would guess there is an external logging config somewhere. Please read https://doc.qt.io/qt-6/qloggingcategory.html#configuring-categories

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                JonBJ 1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  I would guess there is an external logging config somewhere. Please read https://doc.qt.io/qt-6/qloggingcategory.html#configuring-categories

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote last edited by JonB
                  #7

                  @Christian-Ehrlicher
                  To be fair the OP reports

                  Running in debug mode, qDebug() doesn't show messages in Qt Creator/Application Output, but when running a terminal manually, it shows.

                  Assuming the executable is compiled the same (e.g. either debug or release) whether it is run from Creator or from a terminal how would some "external logging config" allow for output to terminal in the latter case but not the former? Unless you mean the environment differs such that this logging file is picked up when running from Creator but not outside?

                  @jronald
                  You might verify that if compiled for release instead the behaviour is the same? Also if executed from Creator but as Run rather than Debug does that make any difference?

                  jronaldJ 1 Reply Last reply
                  0
                  • Axel SpoerlA Axel Spoerl

                    Hi and welcome @jronald !
                    please add qInfo() << QT_VERSION_STR << QT_DEBUG and post the output here.
                    Cheers
                    Axel

                    jronaldJ Offline
                    jronaldJ Offline
                    jronald
                    wrote last edited by
                    #8

                    @Axel-Spoerl said in qDebug() doesn't show messages in Qt Creator/Application Output:

                    Hi and welcome @jronald !
                    please add qInfo() << QT_VERSION_STR << QT_DEBUG and post the output here.
                    Cheers
                    Axel

                    #include <QDebug>
                    #include <QtVersion>
                    
                    int main()
                    {
                    #ifdef QT_DEBUG
                        qDebug() << "Test123";
                        qInfo() << QT_VERSION_STR;
                    #else
                        qDebug() << "Test456";
                        qInfo() << QT_VERSION_STR;
                    #endif
                        return 0;
                    }
                    

                    can't output QT_DEBUG as QT_VERSION_STR does, so do it as above.
                    Still no output in "Qt Creator/Application Output", but when run it in a terminal manually, it outputs as below:

                    Test123
                    6.10.1
                    
                    1 Reply Last reply
                    0
                    • JonBJ JonB

                      @Christian-Ehrlicher
                      To be fair the OP reports

                      Running in debug mode, qDebug() doesn't show messages in Qt Creator/Application Output, but when running a terminal manually, it shows.

                      Assuming the executable is compiled the same (e.g. either debug or release) whether it is run from Creator or from a terminal how would some "external logging config" allow for output to terminal in the latter case but not the former? Unless you mean the environment differs such that this logging file is picked up when running from Creator but not outside?

                      @jronald
                      You might verify that if compiled for release instead the behaviour is the same? Also if executed from Creator but as Run rather than Debug does that make any difference?

                      jronaldJ Offline
                      jronaldJ Offline
                      jronald
                      wrote last edited by
                      #9

                      @JonB said in qDebug() doesn't show messages in Qt Creator/Application Output:

                      You might verify that if compiled for release instead the behaviour is the same? Also if executed from Creator but as Run rather than Debug does that make any difference?

                      I've tried debug only.
                      I tried release just now, same as debug, no output in "Qt Creator/Application Output", output in a terminal.

                      1 Reply Last reply
                      0
                      • jronaldJ Offline
                        jronaldJ Offline
                        jronald
                        wrote last edited by
                        #10

                        If check "Projects/Run Settings/Run in terminal", it will show the messages by qDebug() and qInfo().

                        1 Reply Last reply
                        0
                        • jronaldJ Offline
                          jronaldJ Offline
                          jronald
                          wrote last edited by
                          #11

                          It works after adding QT_ASSUME_STDERR_HAS_CONSOLE=1 in "Projects/Run Settings/Environment".
                          But I don't know why.

                          jronaldJ 1 Reply Last reply
                          0
                          • jronaldJ jronald

                            It works after adding QT_ASSUME_STDERR_HAS_CONSOLE=1 in "Projects/Run Settings/Environment".
                            But I don't know why.

                            jronaldJ Offline
                            jronaldJ Offline
                            jronald
                            wrote last edited by jronald
                            #12

                            https://bbs.archlinux.org/viewtopic.php?id=259035

                            Log from Qt Creator is redirected to systemd journal.
                            Maybe Arch Linux maintainers should change some build flag(s) for Qt Creator.

                            I've checked journalctl, the outputs are there.
                            It should be the cause of archlinux, not intuitive, and leaves unnecessary footprints.

                            JonBJ 1 Reply Last reply
                            0
                            • jronaldJ jronald

                              https://bbs.archlinux.org/viewtopic.php?id=259035

                              Log from Qt Creator is redirected to systemd journal.
                              Maybe Arch Linux maintainers should change some build flag(s) for Qt Creator.

                              I've checked journalctl, the outputs are there.
                              It should be the cause of archlinux, not intuitive, and leaves unnecessary footprints.

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote last edited by
                              #13

                              @jronald
                              That looks like it to me for Arch, well found! I can only say I always have Qt from Ubuntu repo and it works, you don't need to set an environment variable.

                              jronaldJ 1 Reply Last reply
                              1
                              • jronaldJ jronald has marked this topic as solved
                              • JonBJ JonB

                                @jronald
                                That looks like it to me for Arch, well found! I can only say I always have Qt from Ubuntu repo and it works, you don't need to set an environment variable.

                                jronaldJ Offline
                                jronaldJ Offline
                                jronald
                                wrote last edited by jronald
                                #14

                                @JonB said in qDebug() doesn't show messages in Qt Creator/Application Output:

                                I can only say I always have Qt from Ubuntu repo and it works, you don't need to set an environment variable.

                                It's the default behaivor of Qt to output to journelctl on linux, https://doc.qt.io/qt-6/qtlogging.html#qDebug

                                qDebug(const char *format, ...)
                                Logs debug message format to the central message handler.
                                

                                I think ubuntu has changed this in a good way.

                                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