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. Capture checkbox check/uncheck via delegates paint?
Forum Updated to NodeBB v4.3 + New Features

Capture checkbox check/uncheck via delegates paint?

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

    I've been unable to get this to work. I have a TreeView with a custom model and in my TreeView's delegate I am trying to capture if a checkbox was checked or unchecked so I added the following to the pain() method.

    void MyTreeViewDelegate::paint(QPainter *painter,
    const QStyleOptionViewItem &option, const QModelIndex &index) const
    {
        // ...
    
        if (option.state & QStyle::State_Off) {
            std::cout << "Checkbox Unchecked!" << std::endl;
        }
    }
    

    But this never gets called. Thoughts?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      bool isChecked = index.data(Qt::CheckStateRole).toBool();
      works for me with treeview and standarditem model.

      1 Reply Last reply
      2

      • Login

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