[PySide] Double click handling or retaining ownership of mouse events
Cristian.Maureira-Fredes at qt.io
Wed Apr 8 14:54:57 CEST 2020
On 4/8/20 2:01 AM, Marco Grubert wrote:
> I am trying to handle single and double-click events differently in a
> 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?
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
The Qt Company GmbH
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin,
Charlottenburg, HRB 144331 B
More information about the PySide