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

Frank Rueter | OHUfx frank at ohufx.com
Sat May 5 05:17:51 CEST 2018


Hi guys,

thanks a lot for you input!
I have changed my code to simply utilise the view's contextMenuEvent, as 
that already has the behaviour I was trying to mimic.
Via the event I can determine the clicked cell and reposition the pop up 
menu relative to the cell's geometry (and limit the active area to the 
bottom part of the cell).
This gives me the expected behaviour without having to have my delegate 
implement any editor at all, so it seems like the best solution here.

Cheers,
frank

On 3/05/18 11:29 PM, mail at herrdiel.de wrote:
>
> Hi,
>
> how about an transparent (but clickable) layer that covers the area 
> you want to catch that click in, while the editor is open? It can span 
> over the cell, the table or the whole window - whatever pleases. If 
> you stack just beneath the editor (z coordinate), it will recieve the 
> click. its only purpose is to close the editor and - if you so wish - 
> to propagate the click further. Opening the editor sets the layer's 
> size as desired, being clicked, the latter can reduce it own size to zero.
>
> Is there no signal or event like "focusLost" or sth. similar? Because 
> that would be the easiest way: to (create and) connect such a signal 
> to the cell.
>
> Sorry for possibly stupid ideas, I am still learning.
>
> Best regards,
>
> Sebastian
>
>
> Am 02.05.2018 um 23:39 schrieb Frank Rueter | OHUfx:
>> 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
>>
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>
> -- 
> http://www.classintouch.de  - Tablet-Software für Lehrer
>
>
> _______________________________________________
> 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/20180505/6febe8f8/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/20180505/6febe8f8/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/20180505/6febe8f8/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/20180505/6febe8f8/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/20180505/6febe8f8/attachment-0003.png>


More information about the Interest mailing list