<?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[QPixmap::grabWindow how to grab mouse cursor ?]]></title><description><![CDATA[<p dir="auto">Sometimes need mouse cursor to point out the position of the screen.<br />
But the way below can not grab mouse cursor.</p>
<pre><code>QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()-&gt;winId());
</code></pre>
]]></description><link>https://forum.qt.io/topic/90665/qpixmap-grabwindow-how-to-grab-mouse-cursor</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 09:28:18 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/90665.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 13 May 2018 08:00:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QPixmap::grabWindow how to grab mouse cursor ? on Thu, 17 May 2018 08:52:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sonichy">@<bdi>sonichy</bdi></a><br />
hi<br />
Can you try<br />
QPoint p = QCursor::pos();<br />
that is global mouse pos. not mapped to local coors for a widget.</p>
]]></description><link>https://forum.qt.io/post/458742</link><guid isPermaLink="true">https://forum.qt.io/post/458742</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 17 May 2018 08:52:46 GMT</pubDate></item><item><title><![CDATA[Reply to QPixmap::grabWindow how to grab mouse cursor ? on Thu, 17 May 2018 09:18:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> Construct a QWidget to get cursor::pos() !</p>
<pre><code>#include &lt;QApplication&gt;
#include &lt;QStandardPaths&gt;
#include &lt;QWidget&gt;
#include &lt;QScreen&gt;
#include &lt;QClipboard&gt;
#include &lt;QDateTime&gt;
#include &lt;QPainter&gt;

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWidget *widget = new QWidget;
    QScreen *screen = QGuiApplication::primaryScreen();
    QPixmap pixmap = screen-&gt;grabWindow(0);
    QPixmap pixmap_mouse(":/mouse.png");
    QPainter painter(&amp;pixmap);
    painter.drawPixmap(widget-&gt;cursor().pos(),pixmap_mouse);
    QApplication::clipboard()-&gt;setPixmap(pixmap, QClipboard::Clipboard);
    QDateTime time = QDateTime::currentDateTime();
    QString filename = time.toString("yyyyMMddhhmmss") + ".jpg";
    QString path = QStandardPaths::standardLocations(QStandardPaths::DesktopLocation).first() + "/" + filename;
    pixmap.save(path,0,100);
    return 0;
}

</code></pre>
]]></description><link>https://forum.qt.io/post/458741</link><guid isPermaLink="true">https://forum.qt.io/post/458741</guid><dc:creator><![CDATA[sonichy]]></dc:creator><pubDate>Thu, 17 May 2018 09:18:30 GMT</pubDate></item><item><title><![CDATA[Reply to QPixmap::grabWindow how to grab mouse cursor ? on Tue, 15 May 2018 15:14:42 GMT]]></title><description><![CDATA[<p dir="auto">Do you mean <a href="http://doc.qt.io/qt-5/qcursor.html#pos" target="_blank" rel="noopener noreferrer nofollow ugc">QCursor::pos</a> ?</p>
]]></description><link>https://forum.qt.io/post/458405</link><guid isPermaLink="true">https://forum.qt.io/post/458405</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 15 May 2018 15:14:42 GMT</pubDate></item><item><title><![CDATA[Reply to QPixmap::grabWindow how to grab mouse cursor ? on Tue, 15 May 2018 15:11:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> Yes, you are right.</p>
<pre><code>QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()-&gt;winId());
QPixmap pixmap_mouse(":/mouse.png");
QPainter painter(&amp;pixmap);
painter.drawPixmap(300,200,pixmap_mouse);
</code></pre>
<p dir="auto">But still can not get system mouse position.</p>
]]></description><link>https://forum.qt.io/post/458402</link><guid isPermaLink="true">https://forum.qt.io/post/458402</guid><dc:creator><![CDATA[sonichy]]></dc:creator><pubDate>Tue, 15 May 2018 15:11:09 GMT</pubDate></item><item><title><![CDATA[Reply to QPixmap::grabWindow how to grab mouse cursor ? on Mon, 14 May 2018 17:06:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sonichy">@<bdi>sonichy</bdi></a><br />
hi<br />
I dont think you can return a pixmap for the system cursors.<br />
Its only if you constructed a custom one using<br />
QCursor::QCursor(const QPixmap &amp;pixmap, int hotX = -1, int hotY = -1)<br />
As far as I know.</p>
]]></description><link>https://forum.qt.io/post/458133</link><guid isPermaLink="true">https://forum.qt.io/post/458133</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Mon, 14 May 2018 17:06:14 GMT</pubDate></item><item><title><![CDATA[Reply to QPixmap::grabWindow how to grab mouse cursor ? on Mon, 14 May 2018 04:07:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> How to convert QCursor to QPixmap ?</p>
<pre><code>QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()-&gt;winId());
QPainter painter(&amp;pixmap);
painter.drawPixmap(500,500,QCursor(Qt::ArrowCursor).pixmap());
</code></pre>
]]></description><link>https://forum.qt.io/post/458001</link><guid isPermaLink="true">https://forum.qt.io/post/458001</guid><dc:creator><![CDATA[sonichy]]></dc:creator><pubDate>Mon, 14 May 2018 04:07:35 GMT</pubDate></item><item><title><![CDATA[Reply to QPixmap::grabWindow how to grab mouse cursor ? on Sun, 13 May 2018 21:15:47 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">That's not the goal of <code>grabWindow</code>, however what you can do is draw the point of interest on the pixmap you get.</p>
]]></description><link>https://forum.qt.io/post/457989</link><guid isPermaLink="true">https://forum.qt.io/post/457989</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 13 May 2018 21:15:47 GMT</pubDate></item></channel></rss>