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. QTreeWidget: Set color text: specified column in specified row [Solved]
Forum Updated to NodeBB v4.3 + New Features

QTreeWidget: Set color text: specified column in specified row [Solved]

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 7.1k 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.
  • Z Offline
    Z Offline
    zvivered
    wrote on last edited by
    #1

    Hello,

    I'm using QTreeWidget.
    This widget contains 8 columns (first column contains the tree)
    The items in some columns are updated every one second.
    I want to set the color of a specified row,column according to the text.

    How can I do it ?
    I managed to set the color of all the items in a column.
    But this is not good enough.

    Thanks,
    Zvika.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      d2uriel
      wrote on last edited by
      #2

      Each QTreeWidgetItem (if this is what you are using) has it's own font. You can set it using "setFont()":http://qt-project.org/doc/qt-5.0/qtreewidgetitem.html#setFont method.

      To be honest I don't really know what problem you have. Can you try to be more specific?

      "Do not judge, and you will never be mistaken." - Jean-Jacques Rousseau

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        I would say, subclassing [[doc:QIdentityProxyModel]] is of help here. You can overwrite the data method and return the color value depending on the text (and/or other constraints).

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          Hi,

          you can't use proxy models for the item based widgets :-)
          proxy models are for model - view widgets.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            Switching to QTreeView + QTreeModel + Proxy model should be fairly easy in this case.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zvivered
              wrote on last edited by
              #6

              Hello,

              I found a solution.

              QTreeWidgetItem->setColor, did the job.

              Thanks,
              Zvika

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved