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. [SOLVED] How to stylize checkable items in a QAbstractItemModel-based model?

[SOLVED] How to stylize checkable items in a QAbstractItemModel-based model?

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

    Suppose a column inside a QAbstractItemModel-based model has the Qt::ItemIsUserCheckable flag of one of the columns set.
    If the model is set to a let's say QTableView, the column displays the native checkbox's state images. Is there a way using a stylesheet set to the QTableView (for instance, could be any QAbstractItemView) or somehow inside the model to provide custom images for the different check states?

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @
      QTableView::indicator
      {
      image: url(":/checkbox.png");
      }

      QTableView::indicator:unchecked:pressed
      {
      image: url(":/checkbox-unchecked.png");
      }

      QTableView::indicator:checked:pressed
      {
      ...
      }
      @

      use more pseudo states if needed...

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • napajejenunedk0N Offline
        napajejenunedk0N Offline
        napajejenunedk0
        wrote on last edited by
        #3

        Great, thanks. I tried without the indicator sub-element.

        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