Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. qtconsole beginner question creator 17
Forum Updated to NodeBB v4.3 + New Features

qtconsole beginner question creator 17

Scheduled Pinned Locked Moved Solved Installation and Deployment
10 Posts 4 Posters 98 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.
  • J Offline
    J Offline
    joshim
    wrote last edited by
    #1

    not sure if this is the right section, so apologies if this should be somewhere else.

    i'm a beginner and had a question about creator 17. i think the install went fine, i've tested it using one of the demo example projects.

    i started learning qt a couple years back but stopped before i got going properly. i remember using the following code to start with a console application:

    #include <QCoreApplication>
    #include <QDebug>
        
        int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
        
        qInfo() << "Hello World!";
        
        return a.exec();
    }
    

    this doesn't do anything in creator 17, so my first question is why doesn't this work?

    also, how can i amend it so that it does?

    thanks.

    1 Reply Last reply
    0
    • aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote last edited by
      #2

      @joshim may it be you arehit by: https://bugreports.qt.io/browse/QTCREATORBUG-33102 ?

      Which plattform are you on, and which Qt Version are you using? Is there anything in the Application Output?

      Regards

      Qt has to stay free or it will die.

      J 1 Reply Last reply
      0
      • aha_1980A aha_1980

        @joshim may it be you arehit by: https://bugreports.qt.io/browse/QTCREATORBUG-33102 ?

        Which plattform are you on, and which Qt Version are you using? Is there anything in the Application Output?

        Regards

        J Offline
        J Offline
        joshim
        wrote last edited by
        #3

        @aha_1980

        linux manjaro (arch based) qt 6.9.1

        application output:

        22:12:39: Starting /home/joshim/Documents/036_code/untitled9/build/Desktop-Debug/untitled9...
        

        nothing happens after that. it doesn't produce a terminal output, but also doesn't crash. it will remain like this until i force the stop.

        the hello world in the help documentation works ok:

        #include <stdio.h>
        
        int main()
        {
            printf("Hello, world\n");
            return 0;
        }
        

        which shows:

        22:01:35: Starting /home/joshim/Documents/036_code/untitled9/build/Desktop-Debug/untitled9...
        Hello, world
        

        that's why i thought the first example must be written out wrong, but you think there might be something up with my install?

        JonBJ 1 Reply Last reply
        0
        • aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote last edited by
          #4

          @joshim I think your program simple stucks in the a.exec(); loop. The qInfo() output might be buffered, that's why you don't see anything.

          Regards

          Qt has to stay free or it will die.

          JonBJ 1 Reply Last reply
          0
          • J joshim

            @aha_1980

            linux manjaro (arch based) qt 6.9.1

            application output:

            22:12:39: Starting /home/joshim/Documents/036_code/untitled9/build/Desktop-Debug/untitled9...
            

            nothing happens after that. it doesn't produce a terminal output, but also doesn't crash. it will remain like this until i force the stop.

            the hello world in the help documentation works ok:

            #include <stdio.h>
            
            int main()
            {
                printf("Hello, world\n");
                return 0;
            }
            

            which shows:

            22:01:35: Starting /home/joshim/Documents/036_code/untitled9/build/Desktop-Debug/untitled9...
            Hello, world
            

            that's why i thought the first example must be written out wrong, but you think there might be something up with my install?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote last edited by
            #5

            @joshim
            You do not say where you are looking for the output (which you either get or do not get)? Since this is a "console" application have you made settings in Creator for this project to open a console window or what? Does that window appear in both cases? When run from Creator the printf() output will appear in the opened console window but I think the qInfo() output will only appear in Creator's Application Output pane or similar.

            J 1 Reply Last reply
            0
            • aha_1980A aha_1980

              @joshim I think your program simple stucks in the a.exec(); loop. The qInfo() output might be buffered, that's why you don't see anything.

              Regards

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote last edited by
              #6

              @aha_1980 said in qtconsole beginner question creator 17:

              The qInfo() output might be buffered, that's why you don't see anything.

              Nah, I really don't think so! qDebug()/qInfo() etc. would be pretty useless if their output gets buffered!

              J.HilkJ 1 Reply Last reply
              0
              • JonBJ JonB

                @aha_1980 said in qtconsole beginner question creator 17:

                The qInfo() output might be buffered, that's why you don't see anything.

                Nah, I really don't think so! qDebug()/qInfo() etc. would be pretty useless if their output gets buffered!

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote last edited by
                #7

                @JonB

                @Christian-Ehrlicher said in qDebug instant output?:

                Since qDebug() is using stdio for it's output the os and std specific io buffering is taking effect

                Also I think, underlying to QDebug << is a QTextStream which is most definitely buffered.

                https://codebrowser.dev/qt5/qtbase/src/corelib/io/qdebug.cpp.html


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                JonBJ 1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @JonB

                  @Christian-Ehrlicher said in qDebug instant output?:

                  Since qDebug() is using stdio for it's output the os and std specific io buffering is taking effect

                  Also I think, underlying to QDebug << is a QTextStream which is most definitely buffered.

                  https://codebrowser.dev/qt5/qtbase/src/corelib/io/qdebug.cpp.html

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

                  @J.Hilk
                  I have used qDebug()/qInfo() for years without it ever doing anything other than immediate output, no buffering, else it would be "useless".

                  If it makes any difference, both output a newline at the end of any string passed to them. stderr should be totally unbuffered, stdio should be at most line-buffered. I don't even know whether you have access to any QDebug()'s QTextStream even if you had to flush it. And IIRC qDebug() etc. create and destroy a QDebug instance or similar --- and the destructor outputs a newline which is why you always get one.

                  @joshim
                  Remove the return a.exec();, so your Qt console app exits after the qInfo(). That should certainly flush if there really is any buffering going on! Do you see the output anywhere after exiting the program like this?

                  1 Reply Last reply
                  0
                  • JonBJ JonB

                    @joshim
                    You do not say where you are looking for the output (which you either get or do not get)? Since this is a "console" application have you made settings in Creator for this project to open a console window or what? Does that window appear in both cases? When run from Creator the printf() output will appear in the opened console window but I think the qInfo() output will only appear in Creator's Application Output pane or similar.

                    J Offline
                    J Offline
                    joshim
                    wrote last edited by
                    #9

                    @JonB i've tried this with "run in terminal" checked and unchecked. same result with either.

                    the printf() output appears in the application output tab in creator, not the terminal tab

                    i removed return a.exec(); and now the application output shows:

                    17:14:31: Starting /home/joshim/Documents/036_code/untitled9/build/Desktop-Debug/untitled9...
                    17:14:31: The command "/home/joshim/Documents/036_code/untitled9/build/Desktop-Debug/untitled9" finished successfully.
                    

                    so it doesn't hang anymore, but there is no output in the terminal tab within creator.

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      joshim
                      wrote last edited by
                      #10

                      ok so judging by everyone's responses i realised it wasn't that the code was out of date and that creator 17 needed updated instructions, rather there was something wrong with my setup.

                      so in case anyone else has this problem with gnome desktop environment, the culprit is gnome's default terminal app "Console". this app has a binary called kxg and i couldn't figure out what instruction to give to creator to launch it. so i installed gnome-terminal and made this the default terminal app. under environment variables in the manage kits section, the terminal command is gnome-terminal -x. this seems to have solved the problem.

                      thanks to everyone who replied. it set me in the right direction!

                      1 Reply Last reply
                      0
                      • J joshim has marked this topic as solved

                      • Login

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