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. how to set the color of 1 colum of the QTreeWidgetItem?
Qt 6.11 is out! See what's new in the release blog

how to set the color of 1 colum of the QTreeWidgetItem?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 778 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.
  • O Offline
    O Offline
    opengpu2
    wrote on last edited by
    #1

    how to set the color of 1 colum of the QTreeWidgetItem?
    background color, and border-color

    VRoninV 1 Reply Last reply
    0
    • O opengpu2

      how to set the color of 1 colum of the QTreeWidgetItem?
      background color, and border-color

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      @opengpu2 said in how to set the color of 1 colum of the QTreeWidgetItem?:

      background color

      item->setData(column,Qt::BackgroundRole,colour);

      border-color

      I don't think QTreeView has borders by default, you'll probably need to save the colour in a user role (item->setData(column,Qt::UserRole,colour);) and then reimplement paint() an a custom QStyledItemDelegate that you then apply on the widget

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      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 Extensions
      • Unsolved