Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Setting QTextBrowser text background color
Qt 6.12 LTS is out! See what's new in the release blog

Setting QTextBrowser text background color

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 2.8k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Is it possible to set individual characters background color in QTextBrowser or QTextEdit ?

    I don't mean font color of text but different colored background squares under individual characters.

    JonBJ 1 Reply Last reply
    0
    • ? A Former User

      Is it possible to set individual characters background color in QTextBrowser or QTextEdit ?

      I don't mean font color of text but different colored background squares under individual characters.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Q139
      Untested, but I assume since both of those accept HTML (you're prepared to use that, right?) you can use stylesheet {background-color: ...} around each individual character? Say like:

      <span style='background-color: red;'>R</span><span style='background-color: green;'>G</span><span style='background-color: blue;'>B</span>...
      

      Unless someone else knows better/a better way?

      ? 1 Reply Last reply
      2
      • JonBJ JonB

        @Q139
        Untested, but I assume since both of those accept HTML (you're prepared to use that, right?) you can use stylesheet {background-color: ...} around each individual character? Say like:

        <span style='background-color: red;'>R</span><span style='background-color: green;'>G</span><span style='background-color: blue;'>B</span>...
        

        Unless someone else knows better/a better way?

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by A Former User
        #3

        @JonB Thanks for correct syntax , solved.
        In syntax background without -color also works.

        JonBJ 1 Reply Last reply
        0
        • ? A Former User

          @JonB Thanks for correct syntax , solved.
          In syntax background without -color also works.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Q139
          Assuming QSS is approximately similar to HTML CSS, background does a lot more than just set the color: https://developer.mozilla.org/en-US/docs/Web/CSS/background. It so happens that background: green; sets the color alone. I would use background-color, no need to abbreviate.

          1 Reply Last reply
          2

          • Login

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