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. [Solved] Color of QString

[Solved] Color of QString

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 5.6k 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.
  • A Offline
    A Offline
    anmol2701
    wrote on last edited by
    #1

    Hi!

    Is it possible to pass color settings with QString?
    I create a QString using two Strings (QString1 and QString2) and display in Qtextedit.
    I want to show second string (Qstring2) with different color in Qtextedit.

    Any Guidance?

    1 Reply Last reply
    0
    • McLionM Offline
      McLionM Offline
      McLion
      wrote on last edited by
      #2

      Look here: http://qt-project.org/doc/qt-4.8/qtextedit.html#setTextColor
      You can also use html.

      1 Reply Last reply
      0
      • p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

        Hi,

        Since you are using QTextEdit it supports Rich Text's so you can set an Html to it using "setHtml":http://qt-project.org/doc/qt-5/qtextedit.html#html-prop. Using an Html document you can set lots of properties.
        For E.g
        @
        ui->textEdit->setHtml("<font color="red">Red text</font> <font color="blue">Blue text</font>");
        @

        157

        1 Reply Last reply
        1

        • Login

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