Results 1 to 10 of 10

Thread: Change colour of QString

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Change colour of QString

    I need help with setting the colour of a string to be green in the beginning and red at the end.
    The problem right now is that spaces that occur between the two colours disapear.
    The code looks like this:

    Qt Code:
    1. QString input = .. what ever the user inputs
    2. QString answer = "foo bar";
    3. QString temp="<font color=\"#00FF00\">";
    4. int i=0;
    5. while (i<input.size()&& i<answer.size() && input[i]==answer[i])
    6. {
    7. temp=temp+input[i];
    8. i++;
    9. }
    10. temp=temp+"</font><font color=\"#FF0000\">"+answermid(i)+"</font>";
    To copy to clipboard, switch view to plain text mode 
    Last edited by Morea; 10th February 2006 at 13:42.

Similar Threads

  1. Custom Model Advice Requested
    By mclark in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 16:26
  2. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  3. Replies: 2
    Last Post: 12th October 2006, 09:17
  4. Converting QString to unsigned char
    By salston in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:10

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.