Results 1 to 6 of 6

Thread: Console apps in Kde Qt

  1. #1
    Join Date
    Jan 2006
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Console apps in Kde Qt

    Hi all,

    I am trying to display the strings and values in console.

    for that i have added CONFIG += console in pro file, but

    I dont know what to use in cpp file to display .

    I tried qtextstream but it doesnt help me.

    plz give me any ideas.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    52
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Console apps in Kde Qt

    if it's for debug purpose use qDebug("Your text goes here");

    Other than that you can use standard c / c++ methods, like:

    printf("Your text");

    or

    std::cout << "Your text";

  3. #3
    Join Date
    Jan 2006
    Location
    N.B. Canada
    Posts
    47
    Thanked 8 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Console apps in Kde Qt

    You can use std::cout just fine. Or if you want, you can do:

    Qt Code:
    1. QTextStream output(stdout);
    2. output << "Hello world!";
    To copy to clipboard, switch view to plain text mode 

    And that will work with standard output. The same is for stdin and stderr.

    Bojan
    The march of progress:
    C:
    printf("%10.2f", x);
    C++:
    cout << setw(10) << setprecision(2) << showpoint << x;
    Java:
    java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
    formatter.setMinimumFractionDigits(2);
    formatter.setMaximumFractionDigits(2);
    String s = formatter.format(x);
    for (int i = s.length(); i < 10; i++) System.out.print(' ');
    System.out.print(s);

  4. #4
    Join Date
    Jan 2006
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: Console apps in Kde Qt

    Thank you Mike and Bojan,

    I forgot to say my version, I am using 3.3.4 there is no qdebug class.

    and I am working in Linux server, the above methods are not working for me.

  5. #5

    Default Re: Console apps in Kde Qt

    Quote Originally Posted by peedarp
    Thank you Mike and Bojan,

    I forgot to say my version, I am using 3.3.4 there is no qdebug class.

    and I am working in Linux server, the above methods are not working for me.
    the qDebug is present in 3.3.4
    the std::cout is widely used on crossplatforms. So it is not platform related. Just if u use cout, try to put 'using namespace std' after the declarations...or the problem is other?
    I am sailing with the cane...

  6. #6
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Console apps in Kde Qt

    Quote Originally Posted by peedarp
    I am using 3.3.4 there is no qdebug class.
    You're right that there is no such class. But noone told you that there's one
    http://doc.trolltech.com/3.3/qapplication.html#qDebug

Similar Threads

  1. convert console to windows app
    By Max Yaffe in forum Newbie
    Replies: 1
    Last Post: 13th June 2007, 15:38
  2. Console replacement
    By aegis in forum Qt Programming
    Replies: 14
    Last Post: 3rd April 2007, 00:38
  3. How to run a console program "silently"?
    By fullmetalcoder in forum Qt Programming
    Replies: 9
    Last Post: 23rd July 2006, 10:03
  4. QPainter in console apps?
    By Funklord in forum Qt Programming
    Replies: 2
    Last Post: 18th April 2006, 14:03
  5. QT4 console apps
    By ucntcme in forum Newbie
    Replies: 5
    Last Post: 24th January 2006, 10:18

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.