Results 1 to 5 of 5

Thread: Console text color

  1. #1
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Console text color

    Hi All,

    I'm making some console tools and would like it to highlight directories etc as appropriate.

    Anyone know how I could do this in Qt and whether it would impact functionality on windows (not really a concern, but if I can leave it cross platform then it'd be nice).

    Cheers,

    Alan.

  2. #2
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Console text color

    You can use the ascii color codes with qDebug() in unix flavours. And in windows maybe remove those and implement windows specific code ( Not really sure how it can be done in windows console )

    Just found this
    http://www-128.ibm.com/developerwork.../l-tip-prompt/
    http://www.linuxfocus.org/English/Ma...ticle335.shtml
    http://www.expertsrt.com/tutorials/Matt/CmdPrompt.html
    Last edited by sunil.thaha; 11th December 2006 at 15:26.
    We can't solve problems by using the same kind of thinking we used when we created them

  3. #3
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Console text color

    Hi Sunil,

    Thanks very much :-) I got it working with

    QTextStream qout(stdout);
    qout << "\033[0;32mSeqLs Constructor\033[0;0m\n";

    I'll just need to implement processing of the LS_COLORS environment variable and it should follow the users preferences.

    Cheers,

    Alan.

  4. #4
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Console text color

    Hi Sunil,

    Thanks very much :-) I got it working with

    QTextStream qout(stdout);
    qout << "\033[0;32mSeqLs Constructor\033[0;0m\n";

    I'll just need to implement processing of the LS_COLORS environment variable and it should follow the users preferences.

    Cheers,

    Alan.

  5. #5
    Join Date
    Aug 2006
    Location
    Switzerland
    Posts
    52
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Console text color

    Acording to wikipedia you need some kind of device driver (ANSI.SYS), to get it working under Windows. I don't know if it is installed by default.
    The Wheel weaves as the Wheel wills.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Replies: 52
    Last Post: 10th December 2006, 14:32
  3. Setting text color on QLabel
    By Yorma in forum Newbie
    Replies: 11
    Last Post: 15th June 2006, 07:25
  4. Replies: 1
    Last Post: 17th March 2006, 08:19
  5. Change the text color tab page
    By gtthang in forum Qt Programming
    Replies: 4
    Last Post: 18th February 2006, 17:38

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.