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 color any row of Qtablewidget if cell (row, 1) have text (Total) ?
Forum Updated to NodeBB v4.3 + New Features

How to color any row of Qtablewidget if cell (row, 1) have text (Total) ?

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

    How to color any row of Qtablewidget if cell (row, 1) have text (Total) ?

    1 Reply Last reply
    0
    • nabilmkN Offline
      nabilmkN Offline
      nabilmk
      wrote on last edited by
      #2

      help me guys plz

      JonBJ 1 Reply Last reply
      0
      • nabilmkN nabilmk

        help me guys plz

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @nabilmk
        I wouldn't do it with a QTableWidget. That is a convenience widget which is a QTreeView QTableView plus its own inbuilt model, but you cannot easily change the model's behavior.

        I would do it with my own QTreeView QTableView and model (e.g. QStandardItemModel). Then you can subclass the model and override its data() method. There you can returned desired color for the Qt::BackgroundRole or Qt::ForegroundRole roles. You can look at other cells in the row to decide how you want cells colored, so you can see if the first column has text (Total) or whatever.

        1 Reply Last reply
        2
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          It is a QTableView that underlies a QTableWidget, but @JonB's suggestion is a good one and really only needs to involve the model.

          JonBJ 1 Reply Last reply
          0
          • C ChrisW67

            It is a QTableView that underlies a QTableWidget, but @JonB's suggestion is a good one and really only needs to involve the model.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @ChrisW67 said in How to color any row of Qtablewidget if cell (row, 1) have text (Total) ?:

            It is a QTableView that underlies a QTableWidget

            Whoops, corrected :)

            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