Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use font color in Qstring
Forum Updated to NodeBB v4.3 + New Features

How to use font color in Qstring

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.7k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    prankur.sarbhai
    wrote on last edited by
    #1

    Hi,

    I have a string which i need to update with different fonts. Following is the value in Qstring on starting
    QString a = "displayName1(sip:abc@proxy.com), displayname2(sip:xyz@proxy.com)".

    Later it get updated as follows with "connected" shown in red font:

    "displayName1(sip:abc@proxy.com) - connected, displayname2(sip:xyz@proxy.com) - connected".

    I was using QString text(tr(" - <FONT COLOR=red>Connected</FONT>")); for addeing connected in bewteen the string

    Till here it was working fine.

    But now i changed the string to
    QString a = "displayName1sip:abc@proxy.com, displayname2sip:xyz@proxy.com". And added connected in between the string.

    But now its shown as
    "displayName1sip:abc@proxy.com - <FONT COLOR=red>Connected</FONT>, displayname2sip:xyz@proxy.com - <FONT COLOR=red>Connected</FONT>".

    Somehow the problem started when i start using "<>" in string other then font color change. Can someone please explain me what I am doing wrong and how to correct this problem.

    Thanks,
    Prankur

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Using <> like that you are creating an opening tag with no ending so you are creating an invalid html document. You have to escape this character if you want to use it "as is"

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Offline
        B Offline
        butterface
        wrote on last edited by
        #3

        Shouldn't there be <html> and </html> as well?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          IIRC, no. Maybe using the terms "html document" is not the best description. You can do rich text with QLabel but it's not a browser.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

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