<?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[Strange behavior for mousePressEvent]]></title><description><![CDATA[<p dir="auto">Hello,<br />
I'm developing custom serial touchscreen-like driver around Linux evdev events. We have QT5 application on ARM mobile platform and I'm stuck with strange behavior inside QT events. The driver itself simulates an absolute mouse and, I'm confident, works fine on kernel level.<br />
QT environment is configured like this :</p>
<p dir="auto">export QT_QPA_EVDEV_MOUSE_PARAMETERS /dev/input/event2<br />
export QT_QPA_GENERIC_PLUGINS evdevmouse:abs:/dev/input/event2</p>
<p dir="auto">The driver sends (X Y) coordinates, button and button state in following format:<br />
(X,Y, btn_number, btn_state).<br />
So I'm sending (100,100, 1, 1) expecting mouse left button press in 100,100 location. And eventually  (100,100, 1, 0) to release button. What I'm calling strange, inside the QT mousePressEvent() the first click is always shown as (0,0,1,1) when in reality I'm sending (100,100, 1, 1) . Then all following clicks will have an offset of (100,100). It looks like the first coordinates are setting up some kind of relative offset. So following this logic, I need to send (200,200,1,1) to have a click in (100,100, 1, 1). To make it work properly I have to always send the first click to (0,0, 1, 1) then magically everything works until the system reboot. There is no accumulation so it's not like QT is not set to ABS. It will be always the exact same offset using the first click coordinates as value.<br />
So this is not on kernel driver level, I see the data on evtest /dev/input/event2 and the data is valid. It's just QT taking the first click coordinates as reference point!<br />
Any advise where I should look to fix this?</p>
<p dir="auto">Thanks all!</p>
]]></description><link>https://forum.qt.io/topic/144932/strange-behavior-for-mousepressevent</link><generator>RSS for Node</generator><lastBuildDate>Thu, 01 Oct 2026 06:48:27 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/144932.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 06 May 2023 21:28:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Strange behavior for mousePressEvent on Sun, 07 May 2023 07:35:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/latedev">@<bdi>lateDev</bdi></a> said in <a href="/post/757344">Strange behavior for mousePressEvent</a>:</p>
<blockquote>
<p dir="auto">I don't have qevdevmousemanager sources, only .h in my environment.<br />
And my .h is quite different from the one in your link.</p>
</blockquote>
<p dir="auto">The platform interface has a history of being more volatile. If the vendor is reasonably responsive, asking for a full copy might might save a lot of time.</p>
<blockquote>
<p dir="auto">My handleMouseEvent() doesn't have bool abs parameter which brings me to think that perhaps it's not made to work with absolute mouses. Is there any possibility to add this function to my environment? What would be the library to recompile?<br />
I don't have sources but these are all QT libraries I have in my environment:</p>
</blockquote>
<p dir="auto">The absolute coordinate change originates with commit 1d4a1be - <a href="https://codereview.qt-project.org/c/qt/qtbase/+/81593" target="_blank" rel="noopener noreferrer nofollow ugc">https://codereview.qt-project.org/c/qt/qtbase/+/81593</a><br />
That was merged in March of 2014. It looks like the change made it into Qt 5.4.0.</p>
<blockquote>
<p dir="auto">libQt5Core.so.5.3.2</p>
</blockquote>
<p dir="auto">That concurs with my investigation. If you have any reasonable route to upgrade, it will save a lot of headaches.</p>
]]></description><link>https://forum.qt.io/post/757348</link><guid isPermaLink="true">https://forum.qt.io/post/757348</guid><dc:creator><![CDATA[jeremy_k]]></dc:creator><pubDate>Sun, 07 May 2023 07:35:25 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior for mousePressEvent on Sun, 07 May 2023 07:12:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jeremy_k">@<bdi>jeremy_k</bdi></a><br />
Thank you for suggestions!<br />
Putting all config in QT_QPA_EVDEV_MOUSE_PARAMETERS doesn't work, if I remove<br />
QT_QPA_GENERIC_PLUGINS evdevmouse<br />
QT stops receiving events.<br />
So I'm stuck with :<br />
export QT_QPA_EVDEV_MOUSE_PARAMETERS /dev/input/event2:abs<br />
export QT_QPA_GENERIC_PLUGINS evdevmouse<br />
which seems to translate driver events to QT.<br />
I don't have qevdevmousemanager sources, only .h in my environment.<br />
And my .h is quite different from the one in your link.<br />
Yours is:</p>
<pre><code>class QEvdevMouseManager : public QObject
{
public:
    QEvdevMouseManager(const QString &amp;key, const QString &amp;specification, QObject *parent = nullptr);
    ~QEvdevMouseManager();
    void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons,
                          Qt::MouseButton button, QEvent::Type type);
    void handleWheelEvent(QPoint delta);
    void addMouse(const QString &amp;deviceNode = QString());
    void removeMouse(const QString &amp;deviceNode);
private:
    void clampPosition();
    void updateDeviceCount();
    QString m_spec;
    QtInputSupport::DeviceHandlerList&lt;QEvdevMouseHandler&gt; m_mice;
    int m_x;
    int m_y;
    int m_xoffset;
    int m_yoffset;
};
</code></pre>
<p dir="auto">And this is mine:</p>
<pre><code>class QEvdevMouseManager : public QObject
{
    Q_OBJECT
public:
    QEvdevMouseManager(const QString &amp;key, const QString &amp;specification, QObject *parent = 0);
    ~QEvdevMouseManager();

    QDeviceDiscovery *deviceDiscovery() { return m_deviceDiscovery; }

public slots:
    void handleMouseEvent(int x, int y, Qt::MouseButtons buttons);
    void handleWheelEvent(int delta, Qt::Orientation orientation);

private slots:
    void addMouse(const QString &amp;deviceNode = QString());
    void removeMouse(const QString &amp;deviceNode);

private:
    QString m_spec;
    QHash&lt;QString,QEvdevMouseHandler*&gt; m_mice;
    QDeviceDiscovery *m_deviceDiscovery;
    int m_x;
    int m_y;
    int m_xoffset;
    int m_yoffset;
};
</code></pre>
<p dir="auto">My handleMouseEvent() doesn't have bool abs parameter which brings me to think that perhaps it's not made to work with absolute mouses. Is there any possibility to add this function to my environment? What would be the library to recompile?<br />
I don't have sources but these are all QT libraries I have in my environment:<br />
<a href="http://libfunnyutil.so" target="_blank" rel="noopener noreferrer nofollow ugc">libfunnyutil.so</a><br />
libfunnyutil.so.1<br />
libfunnyutil.so.1.0<br />
libfunnyutil.so.1.0.0<br />
<a href="http://libQt5Concurrent.so" target="_blank" rel="noopener noreferrer nofollow ugc">libQt5Concurrent.so</a><br />
libQt5Concurrent.so.5<br />
libQt5Concurrent.so.5.3<br />
libQt5Concurrent.so.5.3.2<br />
<a href="http://libQt5Core.so" target="_blank" rel="noopener noreferrer nofollow ugc">libQt5Core.so</a><br />
libQt5Core.so.5<br />
libQt5Core.so.5.3<br />
libQt5Core.so.5.3.2<br />
<a href="http://libQt5DBus.so" target="_blank" rel="noopener noreferrer nofollow ugc">libQt5DBus.so</a><br />
libQt5DBus.so.5<br />
libQt5DBus.so.5.3<br />
libQt5DBus.so.5.3.2<br />
<a href="http://libQt5Gui.so" target="_blank" rel="noopener noreferrer nofollow ugc">libQt5Gui.so</a><br />
libQt5Gui.so.5<br />
libQt5Gui.so.5.3<br />
libQt5Gui.so.5.3.2<br />
<a href="http://libQt5Multimedia.so" target="_blank" rel="noopener noreferrer nofollow ugc">libQt5Multimedia.so</a><br />
libQt5Multimedia.so.5<br />
libQt5Multimedia.so.5.3<br />
libQt5Multimedia.so.5.3.2<br />
<a href="http://libQt5MultimediaWidgets.so" target="_blank" rel="noopener noreferrer nofollow ugc">libQt5MultimediaWidgets.so</a><br />
libQt5MultimediaWidgets.so.5<br />
libQt5MultimediaWidgets.so.5.3<br />
libQt5MultimediaWidgets.so.5.3.2<br />
<a href="http://libQt5Network.so" target="_blank" rel="noopener noreferrer nofollow ugc">libQt5Network.so</a><br />
libQt5Network.so.5<br />
libQt5Network.so.5.3<br />
libQt5Network.so.5.3.2<br />
<a href="http://libQt5PrintSupport.so" target="_blank" rel="noopener noreferrer nofollow ugc">libQt5PrintSupport.so</a><br />
libQt5PrintSupport.so.5<br />
libQt5PrintSupport.so.5.3<br />
libQt5PrintSupport.so.5.3.2<br />
<a href="http://libQt5Sql.so" target="_blank" rel="noopener noreferrer nofollow ugc">libQt5Sql.so</a><br />
libQt5Sql.so.5<br />
libQt5Sql.so.5.3<br />
libQt5Sql.so.5.3.2<br />
<a href="http://libQt5Widgets.so" target="_blank" rel="noopener noreferrer nofollow ugc">libQt5Widgets.so</a><br />
libQt5Widgets.so.5<br />
libQt5Widgets.so.5.3<br />
libQt5Widgets.so.5.3.2<br />
<a href="http://libQt5Xml.so" target="_blank" rel="noopener noreferrer nofollow ugc">libQt5Xml.so</a><br />
libQt5Xml.so.5<br />
libQt5Xml.so.5.3<br />
libQt5Xml.so.5.3.2</p>
]]></description><link>https://forum.qt.io/post/757344</link><guid isPermaLink="true">https://forum.qt.io/post/757344</guid><dc:creator><![CDATA[lateDev]]></dc:creator><pubDate>Sun, 07 May 2023 07:12:35 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior for mousePressEvent on Sun, 07 May 2023 01:36:56 GMT]]></title><description><![CDATA[<p dir="auto">My first step is usually to turn on all debugging output.<br />
export QT_LOGGING_RULES="<em>.</em>=true"</p>
<p dir="auto">QT_DEBUG_PLUGINS=1 might help as well.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/latedev">@<bdi>lateDev</bdi></a> said in <a href="/post/757327">Strange behavior for mousePressEvent</a>:</p>
<blockquote>
<p dir="auto">export QT_QPA_EVDEV_MOUSE_PARAMETERS /dev/input/event2<br />
export QT_QPA_GENERIC_PLUGINS evdevmouse:abs:/dev/input/event2</p>
</blockquote>
<p dir="auto">If QT_QPA_EVDEV_MOUSE_PARAMETERS is not empty, the specification portion of the plugin passed via QT_QPA_GENERIC_PLUGINS is discarded. Either don't use QT_QPA_EVDEV_MOUSE_PARAMETERS, or use that to pass the full configuration, including <code>abs</code>.</p>
<p dir="auto"><a href="https://codebrowser.dev/qt5/qtbase/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp.html#58" target="_blank" rel="noopener noreferrer nofollow ugc">https://codebrowser.dev/qt5/qtbase/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp.html#58</a></p>
<pre><code>QEvdevMouseManager::QEvdevMouseManager(const QString &amp;key, const QString &amp;specification, QObject *parent)
    : QObject(parent), m_x(0), m_y(0), m_xoffset(0), m_yoffset(0)
{
    Q_UNUSED(key);
    QString spec = QString::fromLocal8Bit(qgetenv("QT_QPA_EVDEV_MOUSE_PARAMETERS"));
    if (spec.isEmpty())
        spec = specification;
    auto parsed = QEvdevUtil::parseSpecification(spec);
</code></pre>
]]></description><link>https://forum.qt.io/post/757336</link><guid isPermaLink="true">https://forum.qt.io/post/757336</guid><dc:creator><![CDATA[jeremy_k]]></dc:creator><pubDate>Sun, 07 May 2023 01:36:56 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior for mousePressEvent on Sat, 06 May 2023 23:32:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a><br />
There are different widgets but they all look like this:<br />
void GridWidget::mousePressEvent(QMouseEvent *event)<br />
{<br />
lastPos  = mapToGlobal(event-&gt;pos());<br />
pressPos = mapToGlobal(event-&gt;pos());<br />
printf("[GridWidget] mousePressEvent pos: %d, globalPos: %d, X: %d, Y: %d, globalX: %d, globalY: %d, button:%d\n",<br />
event-&gt;pos(), event-&gt;globalPos(), event-&gt;x(), event-&gt;y(), event-&gt;globalX(), event-&gt;globalY(), event-&gt;button());<br />
}<br />
This printf always returns 0 for coordinates during the first press. Then starts returning (data - offset from the first press) for consecutive presses.</p>
<p dir="auto">By chance, do you know where data goes between:</p>
<p dir="auto">input_report_abs(input_v_mouse, ABS_X, pos-&gt;xPos);<br />
input_report_abs(input_v_mouse, ABS_Y, pos-&gt;yPos);<br />
input_report_key(input_v_mouse, BTN_LEFT, button-&gt;status);<br />
<strong>input_sync(input_v_mouse);</strong></p>
<p dir="auto">in driver and</p>
<p dir="auto"><strong>mousePressEvent()</strong> callback in QT?</p>
<p dir="auto">Perhaps something happens is in this middle layer but I don't know where to look.</p>
<p dir="auto">Thank you!</p>
]]></description><link>https://forum.qt.io/post/757332</link><guid isPermaLink="true">https://forum.qt.io/post/757332</guid><dc:creator><![CDATA[lateDev]]></dc:creator><pubDate>Sat, 06 May 2023 23:32:19 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior for mousePressEvent on Sat, 06 May 2023 22:23:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/latedev">@<bdi>lateDev</bdi></a> said in <a href="/post/757327">Strange behavior for mousePressEvent</a>:</p>
<blockquote>
<p dir="auto">What I'm calling strange, inside the QT mousePressEvent() the first click is always shown as (0,0,1,1)</p>
</blockquote>
<p dir="auto"><em>Where</em> are you calling <em>what</em> code for this <code>mousePressEvent()</code>?  For example, <code>QWidget::mousePressEvent(QMouseEvent *event)</code> has <code>event-&gt;position()</code> (as opposed to <code>globalPosition()</code>) as relative to the widget.  But maybe you know you have a situation/problem outside of this.</p>
]]></description><link>https://forum.qt.io/post/757331</link><guid isPermaLink="true">https://forum.qt.io/post/757331</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Sat, 06 May 2023 22:23:23 GMT</pubDate></item></channel></rss>