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. Change selection text color in QGraphicsTextItem
Forum Updated to NodeBB v4.3 + New Features

Change selection text color in QGraphicsTextItem

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.3k 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.
  • N Offline
    N Offline
    niks1989
    wrote on last edited by
    #1

    as the default behavior is , whenever you select text in qgraphicstextitem, it shows blue color rectangle and make selected text color white, i need original color to be there at the time of selection

    for ex. if i have a qgraphicstextitem text is yellow in color, then if i select some text , then blue color rectangle will come and text color should be in same .. yellow.

    1 Reply Last reply
    0
    • N Offline
      N Offline
      niks1989
      wrote on last edited by
      #2

      there are 2 solutions to it...
      First i can set QApplication.setPalette()
      and second is to set css in setHtml of qgraphicstextitem

      i need to go by second route....
      can anybody help me in doing so .... i need to change selected/ highlighted text color in textitem of xyz color and selected/highlighted backgound color to be in abc color ?????

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tzander
        wrote on last edited by
        #3

        We explicitly did not make the original yellow text yellow since it would be unreadable with a blue background.
        The palette also is designed to have a selected-text and selected-background color that are system-wide. This is designed as such by Windows and Mac and others.

        If you really want to keep the original color, this likely means you don't want to use a selection. Maybe you can paint a rectangle yourself?
        Also be ready for complaints about text being unreadable when you ignore 20 year old rules ;)

        1 Reply Last reply
        0
        • N Offline
          N Offline
          niks1989
          wrote on last edited by
          #4

          @Thomos

          boss what powerpoint does, it also has textitem , whenever u select some text in that textitem, it shows blus color rectangle, and keeps the selected text in original color, it doesnt change the color to hard code WHITE...

          i also want that functionality , i searched a lot, then i came to know that i achieve this by setting QApplication. setPalette () or by setting CSS in setHtml() of qgraphicstextitem...
          i tried some css selection color change in simple html file which i ran in mozzila , it works well , it gave what ever i set the selection text color , and selection backgound color

          well but same code doesnt work in setHtml() .

          @
          <html>
          <head>
          <style type="text/css">

          p{
          selection-color: #FFFF00;
          selection-background-color: #FF0000;
          }

          </style>

          </head>
          <p>
          nikhil is good boy
          </p>
          <body>
          </body>
          </html>
          @

          1 Reply Last reply
          0
          • N Offline
            N Offline
            niks1989
            wrote on last edited by
            #5

            @thomas

            in simple words, i want to change this selection background color and selection text color, well unreadability is the different thing.

            for solving unreadability i will choose some good colors.

            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