[PySide] Double click handling or retaining ownership of mouse events

Cristián Maureira-Fredes Cristian.Maureira-Fredes at qt.io
Wed Apr 8 14:54:57 CEST 2020

Hello Marco,

On 4/8/20 2:01 AM, Marco Grubert wrote:
> Hello,
> I am trying to handle single and double-click events differently in a 
> QToolButton.
>  From what I have read in forums, Qt does not filter out single click 
> events when a double click occurs, in other words there will always be a 
> mousePressEvent emitted even if it's actually a double-click. The 
> recommended approach in C++ appears to be launching a timer and 
> deferring single click handling.
> a) If there is a better approach, please let me know!
> b) I tried the implementation below, but in the timerExpired function I 
> get the dreaded "Internal C++ object (PySide2.QtGui.QMouseEvent) already 
> deleted" error. I guess storing it in a member variable is insufficient?
> (snip)

I would rather base the implementation on the 'doubleClickInterval()'
for the QTimer, and use a boolean variable to handle when it's
single or double click, so you can then implement

You can check an implementation here:

Not sure if it's better than your approach,
but at least it's simpler IMHO.

Let me know if that's enough, otherwise, we can try to address the
C++ issues you are having in your code.


Dr. Cristian Maureira-Fredes
R&D Manager

The Qt Company GmbH
Erich-Thilo-Str. 10
D-12489 Berlin

Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht
Charlottenburg, HRB 144331 B

More information about the PySide mailing list