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. QTableView custom styling

QTableView custom styling

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

    Hello, all.

    The concrete desired behavior is: color selective QTableView's rows based on some data provided by the used model e.g. a given role has special value. The possible ways to do it:

    1. Use stylesheet. Here comes the question: how to differentiate which cells are having the desired value for the given role?
    2. Provide the necessary cosmetic data through the model. The problem is that the data variety that could be provided this way is constrained to the background and foreground QBrushes and the text font and alignment. Also, noticed that it is not working 100% of the time and can't tell whether this cosmetic data would be overridden or not by a stylesheet if the latter is used in addition.
    3. Implement 1. by reading the given role's value in a subclassed QStyledItemDelegate and customize the QStyleOptionViewItem instance in the QStyledItemDelegate::paint member function.

    It would be best if 1. is somehow possible. If it is or if there's another more integrated approach aside the delegate one (3.) it would be great. Any suggestions are welcome.

    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