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. Multicolored text for tree/table/list items?
QtWS25 Last Chance

Multicolored text for tree/table/list items?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.5k Views
  • 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.
  • R Offline
    R Offline
    reactive
    wrote on last edited by
    #1

    What is the fastest way to make the text of a tree item multicolored?
    Like this: <black>Text</black><red>123</red>
    I did some googling and found QStyledItemDelegate?
    I don't see how to set the colors for regions though.
    Do the items support html?

    Thank you!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      By default: no. I have some code lying around that can do it, but it is not ready to be released. Vote for the associated "bug report":https://bugreports.qt.nokia.com/browse/QTBUG-14200 please.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        reactive
        wrote on last edited by
        #3

        Nuts. That would have been great to have.
        If it become important, I think I can put a solution together using a QStyledItemDelegate.
        I went to vote, but I guess they use different credentials so I have to create an account.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sigrid
          wrote on last edited by
          #4

          The following "FAQ ":http://developer.qt.nokia.com/faq/answer/how_can_i_modify_the_color_for_individual_words_for_items_in_a_view provides an example that illustrates how this can be done by reimplementing "QItemDelegate::paint":http://doc.qt.nokia.com/latest/qitemdelegate.html.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            I don't think the solution presented in that FAQ is very usable. Nice if you want to render one fixed word in a fixed color, but it does nothing to support rendering actual rich text in an item view.

            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