[Interest] QTableView - only trigger edit event in lower part of cell

Frank Rueter | OHUfx frank at ohufx.com
Wed May 2 23:39:16 CEST 2018


I got things working now to open the editor only when the bottom part of 
the cell is clicked but I cannot for the life of me figure out how to 
close it when the user clicks away from the open combo box into the 
upper part of the current cell.
Attached is a simplified working example of where I'm at.

Can somebody please help me figure out that last bit? Here are some 
screen shots to clarify:

The initial table:


The table with the open editor after clicking into the bottom 20 pixels 
of a cell:


The table after I click away from the editor but into the same cell, in 
which case I'd like to close it and show the initial state as seen 
above, but I just can't figure out how to.



Cheers,
frank

On 2/05/18 10:58 AM, Frank Rueter | OHUfx wrote:
> Ah, looks like my approach was correct but I had not turned off edit 
> triggers properly, so those were interfering with the expected behaviour.
>
> On 1/05/18 8:21 PM, Frank Rueter | OHUfx wrote:
>> Hi,
>>
>> I have spent several hours trying to get this right but seem to be 
>> failing:
>> I have a QTableView (which uses a QAbstractTableModel) and a custom 
>> delegate which takes care of the cell painting.
>> At the bottom of each cell I need a combo box which I want editable 
>> by a single click, so no clicking to select or focus the cell first. 
>> Here is the current state of a cell:
>>
>> I tried this via the view's mousePressEvent, comparing 
>> self.visualRect(index) to the cursor position (after mapping both to 
>> the global coordinate system. But I can't get that right.
>>
>> Another attempt was to do it via the delegate's createEditor() method 
>> and just return None if the cursor isn't in the required area.
>> That seemed to be more promising, but I didn't know how to close the 
>> editor again when the user clicks into the upper part of the cell.
>>
>> I want to avoid persistent editors for performance reasons.
>>
>> Does anybody have any tips how to best tackle this? It feels like it 
>> shouldn't be too hard and I have stared at it too long now to see any 
>> obvious solutions, so any help would be great.
>>
>> Cheers,
>> frank
>>
>>
>>
>>
>>
>>
>> -- 
>>
>> ohufxLogo 50x50 <http://www.ohufx.com> 	
>> 	*vfx compositing <http://ohufx.com/compositing.html> | *workflow 
>> customisation and consulting <http://ohufx.com/customising.html>* *
>> 		*<http://ohufx.com/compositing.html>*
>> <http://www.nukepedia.com/nubridge> 	
>> 	
>>
>> Your gateway to over 1,000 free tools... right inside of Nuke 
>> <http://www.nukepedia.com/nubridge>
>>
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180503/3cfd7e1b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2018-05-02 at 6.27.47 PM.png
Type: image/png
Size: 20665 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180503/3cfd7e1b/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2018-05-02 at 6.27.52 PM.png
Type: image/png
Size: 28188 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180503/3cfd7e1b/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2018-05-02 at 6.27.57 PM.png
Type: image/png
Size: 22408 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180503/3cfd7e1b/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2018-05-01 at 8.13.58 PM.png
Type: image/png
Size: 45093 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180503/3cfd7e1b/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: delegate_test.py
Type: text/x-python-script
Size: 5731 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180503/3cfd7e1b/attachment.bin>


More information about the Interest mailing list