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. QTreeView - Item to have multiple colours
Forum Update on Monday, May 27th 2025

QTreeView - Item to have multiple colours

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 539 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.
  • K Offline
    K Offline
    kumararajas
    wrote on last edited by
    #1

    Hello,

    Is there a way that, I can set multiple colours on the item being displayed?

    Example:

    |
    --- Hello World
       |
       --- My Data
       |
    

    In this, I want to show Hello in blue colour, World in red colour. And "My" in purple colour and "Data" in black colour.

    How to achieve this?

    Thanks for your help in advance.

    --Kumara

    --Kumar

    1 Reply Last reply
    0
    • T Offline
      T Offline
      takoo
      wrote on last edited by
      #2

      You must research Qregexp and QTextCursor

      I just write code ------- (-_-) ----------

      1 Reply Last reply
      0
      • Ni.SumiN Offline
        Ni.SumiN Offline
        Ni.Sumi
        wrote on last edited by
        #3

        hi @kumararajas ,

        seems, you can achieve this using QStyledItemDelegate::paint(painter, newOption, index); .
        Check this post.

        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