[Interest] Set QTableWidgetItem checkbox when clicking anywhere on QTableWidget's row

André Somers andre at familiesomers.nl
Thu Jul 6 20:18:58 CEST 2017



Op 06/07/2017 om 17:47 schreef Murphy, Sean:
>>> And then with the event filter approach, what would I actually be filtering
>> on? 
>   <snip>
>> It's similar to the above, only it solves the same problem at a
>> different location in your code. Instead of modifying a delegate, you'd
>> intercept the mouse click and, again, handle the state change yourself.
>> Indeed the widgetApp isn't going to tell you if you're over the checkbox
>> in the item view as the checkbox there is not a widget but rendered by
>> the delegate directly, but you don't need that info either. All you need
>> to know if the mouse is over a row, and which row. QAbstractItemView can
>> tell you that just fine...
>>
>> In both cases, you simply handle the mouse event yourself, and use
>> setData yourself to toggle the state of the checkbox when there is a
>> click *somewhere* on the row. That's what you were after, right?
> That is what I was after, yes. Just to be clear, in the event filter method, the 
> event filter would intercept the click before it gets to the checkbox correct? 
> And then I would be able to explicitly set the checkbox's state in my handler 
> and avoid the double-toggle that I was experiencing previously? 
That's right. And note, that there is no real checkbox. There is a
rendering of one by the delegate that was set for the given cell. At
least: no widget.

André




More information about the Interest mailing list