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. Setting QTextBrowser text background color
Forum Updated to NodeBB v4.3 + New Features

Setting QTextBrowser text background color

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.9k 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.
  • Q Offline
    Q Offline
    Q139
    wrote on 13 Jun 2020, 12:44 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.

    J 1 Reply Last reply 13 Jun 2020, 12:49
    0
    • Q Q139
      13 Jun 2020, 12:44

      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.

      J Offline
      J Offline
      JonB
      wrote on 13 Jun 2020, 12:49 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?

      Q 1 Reply Last reply 13 Jun 2020, 13:07
      2
      • J JonB
        13 Jun 2020, 12:49

        @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?

        Q Offline
        Q Offline
        Q139
        wrote on 13 Jun 2020, 13:07 last edited by Q139
        #3

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

        J 1 Reply Last reply 13 Jun 2020, 13:16
        0
        • Q Q139
          13 Jun 2020, 13:07

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

          J Offline
          J Offline
          JonB
          wrote on 13 Jun 2020, 13:16 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

          1/4

          13 Jun 2020, 12:44

          • Login

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