[PySide] Double click handling or retaining ownership of mouse events
grubertm at hotmail.com
Wed Apr 8 18:49:47 CEST 2020
Thank you for pointing out the doubleClickInterval, Cristián - that looks helpful.
I should clarify that I want to keep the existing implementation for the single click events, and only change behavior when a user double-clicks.
That's where things are going bad. I am trying to call through to the base class for single-clicks but it expects a QMouseEvent and the one I got earlier has apparently been deleted on the C++ side.
From: PySide <pyside-bounces at qt-project.org> on behalf of Cristián Maureira-Fredes <Cristian.Maureira-Fredes at qt.io>
Sent: Wednesday, April 8, 2020 5:54 AM
To: pyside at qt-project.org <pyside at qt-project.org>
Subject: Re: [PySide] Double click handling or retaining ownership of mouse events
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
PySide mailing list
PySide at qt-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PySide