<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Thank you for pointing out the doubleClickInterval, Cristián - that looks helpful.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
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.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
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.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div>
<div id="appendonsend"></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size: 11pt;" data-ogsc=""><b>From:</b> PySide <pyside-bounces@qt-project.org> on behalf of Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io><br>
<b>Sent:</b> Wednesday, April 8, 2020 5:54 AM<br>
<b>To:</b> pyside@qt-project.org <pyside@qt-project.org><br>
<b>Subject:</b> Re: [PySide] Double click handling or retaining ownership of mouse events</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">Hello Marco,<br>
<br>
On 4/8/20 2:01 AM, Marco Grubert wrote:<br>
> Hello,<br>
> <br>
> I am trying to handle single and double-click events differently in a <br>
> QToolButton.<br>
>  From what I have read in forums, Qt does not filter out single click <br>
> events when a double click occurs, in other words there will always be a <br>
> mousePressEvent emitted even if it's actually a double-click. The <br>
> recommended approach in C++ appears to be launching a timer and <br>
> deferring single click handling.<br>
> <br>
> a) If there is a better approach, please let me know!<br>
> b) I tried the implementation below, but in the timerExpired function I <br>
> get the dreaded "Internal C++ object (PySide2.QtGui.QMouseEvent) already <br>
> deleted" error. I guess storing it in a member variable is insufficient?<br>
> (snip)<br>
<br>
I would rather base the implementation on the 'doubleClickInterval()'<br>
for the QTimer, and use a boolean variable to handle when it's<br>
single or double click, so you can then implement<br>
'mouseDoubleClickEvent()'.<br>
<br>
You can check an implementation here:<br>
<a href="https://pastebin.com/Um8b4YrG" style="">https://pastebin.com/Um8b4YrG</a><br>
<br>
Not sure if it's better than your approach,<br>
but at least it's simpler IMHO.<br>
<br>
Let me know if that's enough, otherwise, we can try to address the<br>
C++ issues you are having in your code.<br>
<br>
Cheers<br>
<br>
-- <br>
Dr. Cristian Maureira-Fredes<br>
R&D Manager<br>
<br>
The Qt Company GmbH<br>
Erich-Thilo-Str. 10<br>
D-12489 Berlin<br>
<br>
Geschäftsführer: Mika Pälsi,<br>
Juha Varelius, Mika Harjuaho<br>
Sitz der Gesellschaft: Berlin,<br>
Registergericht: Amtsgericht<br>
Charlottenburg, HRB 144331 B<br>
_______________________________________________<br>
PySide mailing list<br>
PySide@qt-project.org<br>
<a href="https://lists.qt-project.org/listinfo/pyside" style="">https://lists.qt-project.org/listinfo/pyside</a><br>
</div>
</span></font></div>
</div>
</body>
</html>