Results 1 to 14 of 14

Thread: Qt Console application in Ubuntu

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt Console application in Ubuntu

    Hello,
    I usually run Qt in Windows.
    I created a Qt Console Application in Ubunti with the following code:

    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <QtDebug>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QCoreApplication a(argc, argv);
    7. qDebug()<<"Hello World\n";
    8.  
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    unfortunately it displays nothing at all, like it does in Windows.
    There is a config += console in the project file.
    What did I do wrong?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt Console application in Ubuntu

    Nothing, the program outputs "Hello World" to the terminal just fine (and then does not terminate). How are you starting the program?

  3. #3
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Console application in Ubuntu

    I just click on that run button that looks like a green triangle: |>

    I may have screwed up my installation of Qt by installing an (extra?) Qt debugger when one was already installed by default.
    Maybe I should uninstall all things Qt and reinstall just QtCreator.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt Console application in Ubuntu

    You should see the string in the "Application Output" tab in Qt Creator, just like on Windows.

    Cheers,
    _

  5. #5
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Console application in Ubuntu

    Hi there,
    No nothing in the "Application Output" tab.
    Nothing in the console either.
    If I change the program to add

    #include <stdio.h>
    ...
    printf("Hello again\n");

    there is no visible effect.
    What's more I have uninstalled QtCreator and it asked me to uninstall "debug symbols for Qt Creator"
    I also uninstalled Qt Linguist and Qt Designer.
    Then I reinstalled Qt Creator.
    The application still displays nothing.

  6. #6
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt Console application in Ubuntu

    One possible cause: Qt Creator does not cooperate well with every Linux terminal. Check the terminal setting and make sure that it is xterm -e and not econsole -e or something similar. Try again (try the printf() first).

    I have solved this in Debian but I have got an error output in "Application Output" window at least. The Creator tried some piping somewhere and failed. Setting the console to xterm solved the problem.

  7. #7
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Console application in Ubuntu

    Thanks,
    Could you be more explicit on how you change a terminal setting?

  8. #8
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt Console application in Ubuntu

    Tools -> Options -> Environment

  9. #9
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Console application in Ubuntu

    Thanks Radek. This solved the problem.
    I put xterm -e instead of the initial x-terminal-emulator -e
    The trouble is that this part of the options is very obscure, no drop down list.

  10. #10
    Join Date
    Feb 2014
    Posts
    8
    Qt products
    Qt5
    Platforms
    Windows

    Lightbulb Re: Qt Console application in Ubuntu

    Advice :: remember to always use qDebug()<< function for output in ubuntu/linux because cout<< works only in windows and not in ubuntu/linux
    Last edited by MI; 28th February 2014 at 19:58. Reason: updated contents

  11. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt Console application in Ubuntu

    Umm, no... std::cout is a standard part of the C++ library and is fully functional in both environments.

Similar Threads

  1. How to exit Qt console application?
    By arcelivez in forum Qt Programming
    Replies: 14
    Last Post: 30th July 2014, 08:51
  2. Replies: 8
    Last Post: 23rd August 2012, 19:28
  3. about console application
    By jirach_gag in forum Qt Programming
    Replies: 2
    Last Post: 5th January 2012, 11:39
  4. console output on windows and ubuntu
    By hannesvdc in forum Qt Programming
    Replies: 2
    Last Post: 11th December 2010, 22:43
  5. Replies: 2
    Last Post: 21st November 2010, 18:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.