Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. [Solved] Python/C++ - How to change the color of some text of tree widget items
Forum Updated to NodeBB v4.3 + New Features

[Solved] Python/C++ - How to change the color of some text of tree widget items

Scheduled Pinned Locked Moved Language Bindings
2 Posts 1 Posters 2.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.
  • N Offline
    N Offline
    needhelp_gh
    wrote on last edited by
    #1

    Hi,

    I have this code in c++:

    @item->setForeground(0,Qt::red);@

    to change the color of some text of tree widget items, but I'm not sure how to convert Qt::red to python. Please help!!


    http://abstrusegoose.com/432

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

      Solved it myself :)

      Here is the python code for anyone who needs it in the future:

      @brush = QtGui.QBrush()
      color = QtGui.QColor(R, G, B) # insert RGB values
      brush.setColor(color)
      treeItem.setForeground(0, brush)@

      hope it helps!!


      http://abstrusegoose.com/432

      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