<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[SOLVED]QGraphicsScene::mousePressEvent: Since Qt5.3 the shortest response time is about 190ms after last press event!]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm working on a drum computer application and use QGraphicsView/Scene to draw all<br />
items. One of the main responsibilities are: By pressing of pads the ability to make<br />
a beat (let say on a android pad or on a PC by mouse clicking).</p>
<p dir="auto">For example folowing beat:<br />
@<br />
Basedrum:  X.......X.X.....<br />
Snaredrum: ....X.......X...<br />
@</p>
<p dir="auto">Since Qt5.3 it's no more posible to do this because of some delays (on Win7, Ubuntu 14..., Android 4....).</p>
<p dir="auto">I made a test with a minimal implementation, additionaly test it with QWidget Button too.</p>
<p dir="auto">I execute the app and try click fast as i can:</p>
<p dir="auto">Timings on Qt 5.3.1 --&gt; shortest response time ~190ms</p>
<p dir="auto">Time: 48,593 -- Scene::mousePressEvent<br />
Time: 48,785 -- Scene::mousePressEvent<br />
Time: 48,985 -- Scene::mousePressEvent<br />
Time: 49,169 -- Scene::mousePressEvent<br />
Time: 49,361 -- Scene::mousePressEvent<br />
Time: 35,544 -- MainWindow::on_pushButton_pressed<br />
Time: 35,648 -- MainWindow::on_pushButton_pressed<br />
Time: 35,752 -- MainWindow::on_pushButton_pressed<br />
Time: 35,856 -- MainWindow::on_pushButton_pressed<br />
Time: 35,936 -- MainWindow::on_pushButton_pressed</p>
<p dir="auto">Timings on Qt 5.2.1 --&gt; shortest response time ~90ms:<br />
Time: 20,626 -- Scene::mousePressEvent<br />
Time: 20,714 -- Scene::mousePressEvent<br />
Time: 20,802 -- Scene::mousePressEvent<br />
Time: 20,897 -- Scene::mousePressEvent<br />
Time: 20,985 -- Scene::mousePressEvent<br />
Time: 05,537 -- MainWindow::on_pushButton_pressed<br />
Time: 05,633 -- MainWindow::on_pushButton_pressed<br />
Time: 05,721 -- MainWindow::on_pushButton_pressed<br />
Time: 05,825 -- MainWindow::on_pushButton_pressed<br />
Time: 05,913 -- MainWindow::on_pushButton_pressed</p>
<h2>@main.cpp</h2>
<h2>#include "mainwindow.h"<br />
#include &lt;QApplication&gt;<br />
int main(int argc, char *argv[]) {<br />
QApplication a(argc, argv);<br />
MainWindow w;<br />
w.show();<br />
return a.exec();<br />
}</h2>
<h2>mainwindow.h</h2>
<p dir="auto">#ifndef MAINWINDOW_H<br />
#define MAINWINDOW_H<br />
#include &lt;QMainWindow&gt;</p>
<h2>namespace Ui { class MainWindow; }<br />
class MainWindow : public QMainWindow {<br />
Q_OBJECT<br />
public:<br />
explicit MainWindow(QWidget *parent = 0);<br />
~MainWindow();<br />
private slots:<br />
void on_pushButton_pressed();<br />
private:<br />
Ui::MainWindow *ui;<br />
};<br />
#endif // MAINWINDOW_H</h2>
<h2>mainwindow.cpp</h2>
<p dir="auto">#include "mainwindow.h"<br />
#include "ui_mainwindow.h"<br />
#include &lt;QGraphicsView&gt;<br />
#include &lt;QGraphicsScene&gt;<br />
#include &lt;QTime&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;</p>
<h2>void debug(const QString&amp; cName, const QString&amp; fName) {<br />
QTime time = QTime::currentTime();<br />
std::cout &lt;&lt; "Time: "<br />
&lt;&lt; std::setw(2)&lt;&lt; std::right &lt;&lt; std::setfill('0') &lt;&lt; time.second()<br />
&lt;&lt; ","<br />
&lt;&lt; std::setw(3)&lt;&lt; std::left &lt;&lt; time.msec()<br />
&lt;&lt; " -- " &lt;&lt; cName.toStdString()<br />
&lt;&lt; "::" &lt;&lt; fName.toStdString() &lt;&lt; std::endl;<br />
}<br />
class Scene : public QGraphicsScene {<br />
protected:<br />
virtual void mousePressEvent(QGraphicsSceneMouseEvent* mouseEvent) {<br />
Q_UNUSED(mouseEvent);<br />
debug("Scene", "mousePressEvent");<br />
}<br />
};<br />
MainWindow::MainWindow(QWidget *parent) :<br />
QMainWindow(parent),<br />
ui(new Ui::MainWindow) {<br />
ui-&gt;setupUi(this);<br />
auto rect = ui-&gt;graphicsView-&gt;geometry();<br />
rect.adjust(0, 0, -4, -4);<br />
ui-&gt;graphicsView-&gt;setSceneRect(rect);<br />
ui-&gt;graphicsView-&gt;setScene(new Scene());<br />
}<br />
MainWindow::~MainWindow() {<br />
delete ui;<br />
}<br />
void MainWindow::on_pushButton_pressed() {<br />
debug("MainWindow", "on_pushButton_pressed");<br />
}</h2>
<h2>mainwindow.ui</h2>
<h2>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;ui version="4.0"&gt;<br />
&lt;class&gt;MainWindow&lt;/class&gt;<br />
&lt;widget class="QMainWindow" name="MainWindow"&gt;<br />
&lt;property name="geometry"&gt;<br />
&lt;rect&gt;<br />
&lt;x&gt;0&lt;/x&gt;<br />
&lt;y&gt;0&lt;/y&gt;<br />
&lt;width&gt;196&lt;/width&gt;<br />
&lt;height&gt;96&lt;/height&gt;<br />
&lt;/rect&gt;<br />
&lt;/property&gt;<br />
&lt;property name="windowTitle"&gt;<br />
&lt;string&gt;MainWindow&lt;/string&gt;<br />
&lt;/property&gt;<br />
&lt;widget class="QWidget" name="centralWidget"&gt;<br />
&lt;widget class="QPushButton" name="pushButton"&gt;<br />
&lt;property name="geometry"&gt;<br />
&lt;rect&gt;<br />
&lt;x&gt;10&lt;/x&gt;<br />
&lt;y&gt;10&lt;/y&gt;<br />
&lt;width&gt;75&lt;/width&gt;<br />
&lt;height&gt;71&lt;/height&gt;<br />
&lt;/rect&gt;<br />
&lt;/property&gt;<br />
&lt;property name="text"&gt;<br />
&lt;string&gt;PushButton&lt;/string&gt;<br />
&lt;/property&gt;<br />
&lt;/widget&gt;<br />
&lt;widget class="QGraphicsView" name="graphicsView"&gt;<br />
&lt;property name="geometry"&gt;<br />
&lt;rect&gt;<br />
&lt;x&gt;110&lt;/x&gt;<br />
&lt;y&gt;10&lt;/y&gt;<br />
&lt;width&gt;71&lt;/width&gt;<br />
&lt;height&gt;71&lt;/height&gt;<br />
&lt;/rect&gt;<br />
&lt;/property&gt;<br />
&lt;/widget&gt;<br />
&lt;/widget&gt;<br />
&lt;/widget&gt;<br />
&lt;layoutdefault spacing="6" margin="11"/&gt;<br />
&lt;resources/&gt;<br />
&lt;connections/&gt;<br />
&lt;/ui&gt;</h2>
<h2><a href="http://TestQTGUIStuff.pro" target="_blank" rel="noopener noreferrer nofollow ugc">TestQTGUIStuff.pro</a></h2>
<h2>QT += core gui<br />
TARGET = TestQTGUIStuff<br />
TEMPLATE = app<br />
CONFIG += c++11<br />
SOURCES += main.cpp<br />
mainwindow.cpp<br />
HEADERS += mainwindow.h<br />
FORMS += mainwindow.ui</h2>
<p dir="auto">@</p>
<p dir="auto">Is there something which i forgot to set up or do not correctly program?<br />
What changes with Qt5.3 that this behaviour happens?</p>
<p dir="auto">Thank you in advance!</p>
]]></description><link>https://forum.qt.io/topic/47060/solved-qgraphicsscene-mousepressevent-since-qt5-3-the-shortest-response-time-is-about-190ms-after-last-press-event</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 01:59:43 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/47060.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Oct 2014 11:10:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED]QGraphicsScene::mousePressEvent: Since Qt5.3 the shortest response time is about 190ms after last press event! on Fri, 17 Oct 2014 08:50:10 GMT]]></title><description><![CDATA[<p dir="auto">[SOLVED]</p>
<p dir="auto">i compare the<br />
"void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e)" function of qt5.2.1 and qt5.4</p>
<p dir="auto">Because of "Qt QTBUG-25831Event behavior for QEvent::MouseButtonDblClick changed since Qt 4"</p>
<p dir="auto">The solution is: override also QGraphicsScene::mouseDoubleClickEvent and use it as a normal mousePressEvent.</p>
<p dir="auto">@<br />
class Scene : public QGraphicsScene<br />
{<br />
protected:<br />
virtual void mousePressEvent(QGraphicsSceneMouseEvent* mouseEvent)<br />
{<br />
Q_UNUSED(mouseEvent);<br />
debug("Scene", "mousePressEvent");<br />
}<br />
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* mouseEvent)<br />
{<br />
Q_UNUSED(mouseEvent);<br />
debug("Scene", "mouseDoubleClickEvent");<br />
}<br />
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* mouseEvent)<br />
{<br />
Q_UNUSED(mouseEvent);<br />
debug("Scene", "mouseReleaseEvent");<br />
}<br />
};<br />
@</p>
<p dir="auto">Time: 35,827 -- Scene::mousePressEvent<br />
Time: 35,859 -- Scene::mouseReleaseEvent<br />
Time: 35,931 -- Scene::mouseDoubleClickEvent<br />
Time: 35,955 -- Scene::mouseReleaseEvent<br />
Time: 36,270 -- Scene::mousePressEvent<br />
Time: 36,510 -- Scene::mouseReleaseEvent<br />
Time: 36,123 -- Scene::mouseDoubleClickEvent<br />
Time: 36,163 -- Scene::mouseReleaseEvent<br />
Time: 36,219 -- Scene::mousePressEvent<br />
Time: 36,267 -- Scene::mouseReleaseEvent<br />
Time: 36,331 -- Scene::mouseDoubleClickEvent<br />
Time: 36,379 -- Scene::mouseReleaseEvent<br />
Time: 36,443 -- Scene::mousePressEvent<br />
Time: 36,483 -- Scene::mouseReleaseEvent<br />
Time: 36,547 -- Scene::mouseDoubleClickEvent<br />
Time: 36,595 -- Scene::mouseReleaseEvent<br />
Time: 36,643 -- Scene::mousePressEvent<br />
Time: 36,691 -- Scene::mouseReleaseEvent<br />
Time: 36,747 -- Scene::mouseDoubleClickEvent<br />
Time: 36,803 -- Scene::mouseReleaseEvent<br />
Time: 36,859 -- Scene::mousePressEvent<br />
Time: 36,899 -- Scene::mouseReleaseEvent<br />
Time: 36,955 -- Scene::mouseDoubleClickEvent<br />
Time: 37,270 -- Scene::mouseReleaseEvent</p>
]]></description><link>https://forum.qt.io/post/247958</link><guid isPermaLink="true">https://forum.qt.io/post/247958</guid><dc:creator><![CDATA[vdc82]]></dc:creator><pubDate>Fri, 17 Oct 2014 08:50:10 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED]QGraphicsScene::mousePressEvent: Since Qt5.3 the shortest response time is about 190ms after last press event! on Thu, 16 Oct 2014 12:05:29 GMT]]></title><description><![CDATA[<p dir="auto">And the same with MSVS2010  (~190ms):</p>
<p dir="auto">Time: 12,165 -- Scene::mousePressEvent<br />
Time: 12,357 -- Scene::mousePressEvent<br />
Time: 12,549 -- Scene::mousePressEvent<br />
Time: 12,749 -- Scene::mousePressEvent<br />
Time: 12,933 -- Scene::mousePressEvent<br />
Time: 13,125 -- Scene::mousePressEvent<br />
Time: 13,309 -- Scene::mousePressEvent<br />
Time: 13,509 -- Scene::mousePressEvent</p>
<p dir="auto">qt-opensource-windows-x86-msvc2010_opengl-5.4.0-beta_2014-10-15_12-07-18-43.exe</p>
]]></description><link>https://forum.qt.io/post/247802</link><guid isPermaLink="true">https://forum.qt.io/post/247802</guid><dc:creator><![CDATA[vdc82]]></dc:creator><pubDate>Thu, 16 Oct 2014 12:05:29 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED]QGraphicsScene::mousePressEvent: Since Qt5.3 the shortest response time is about 190ms after last press event! on Thu, 16 Oct 2014 11:06:58 GMT]]></title><description><![CDATA[<p dir="auto">5.4 seems to be the same, still 190ms.<br />
I compared qtbase\src\widgets\graphicsview 5.2.1 and 5.3.2 code and could not find any indications. Must be somewhere deeper....<br />
pushButton still works fast.</p>
]]></description><link>https://forum.qt.io/post/247779</link><guid isPermaLink="true">https://forum.qt.io/post/247779</guid><dc:creator><![CDATA[vdc82]]></dc:creator><pubDate>Thu, 16 Oct 2014 11:06:58 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED]QGraphicsScene::mousePressEvent: Since Qt5.3 the shortest response time is about 190ms after last press event! on Thu, 16 Oct 2014 09:42:18 GMT]]></title><description><![CDATA[<p dir="auto">qt-opensource-windows-x86-mingw482_opengl-5.4.0-beta_2014-10-15_12-07-18-43.exe</p>
<p dir="auto">Time: 48,222 -- Scene::mousePressEvent<br />
Time: 48,414 -- Scene::mousePressEvent<br />
Time: 48,589 -- Scene::mousePressEvent<br />
Time: 48,757 -- Scene::mousePressEvent<br />
Time: 48,950 -- Scene::mousePressEvent<br />
Time: 49,133 -- Scene::mousePressEvent<br />
Time: 49,309 -- Scene::mousePressEvent</p>
]]></description><link>https://forum.qt.io/post/247767</link><guid isPermaLink="true">https://forum.qt.io/post/247767</guid><dc:creator><![CDATA[vdc82]]></dc:creator><pubDate>Thu, 16 Oct 2014 09:42:18 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED]QGraphicsScene::mousePressEvent: Since Qt5.3 the shortest response time is about 190ms after last press event! on Wed, 15 Oct 2014 22:54:42 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Pretty strange indeed,</p>
<p dir="auto">Can you test with the 5.4 beta ?</p>
]]></description><link>https://forum.qt.io/post/247718</link><guid isPermaLink="true">https://forum.qt.io/post/247718</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 15 Oct 2014 22:54:42 GMT</pubDate></item></channel></rss>