<?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]about the coordinates of my screen. Qt]]></title><description><![CDATA[<p dir="auto">I've posted about a problem yesterday of letting the widget completely transparent , but still haven't solved it... any ways there was another solution which it taking a picture of my primary screen and set it as the background of my widget and the user can select what he wants which is a nice idea and it's working.</p>
<p dir="auto">Except at the last thing I should do , which is saving the picture just to check if it's working and I got a weird problem ,</p>
<p dir="auto">when I drag the mouse from the top left it works fine..</p>
<p dir="auto">but when I drag from anywhere like top right it gives me a wrong picture " wrong place or coordinates "</p>
<p dir="auto">first the code that sets the background of my dialog:<br />
@<br />
this-&gt;setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);<br />
this-&gt;setWindowState(Qt::WindowFullScreen);<br />
Image=new QPixmap;<br />
screen=QGuiApplication::primaryScreen();<br />
*Image=screen-&gt;grabWindow(0);<br />
pal.setBrush(this-&gt;backgroundRole(),QBrush(*Image));<br />
this-&gt;setPalette(pal);<br />
@<br />
second the mouse events:<br />
@<br />
void FramelessWindow::mousePressEvent(QMouseEvent *event){<br />
if(event-&gt;button()==Qt::LeftButton){<br />
origin= event-&gt;pos();<br />
rubberBand-&gt;setGeometry(QRect(origin,QSize()));<br />
rubberBand-&gt;show();</p>
<pre><code>    }
}

void FramelessWindow::mouseMoveEvent(QMouseEvent *event){
    rubberBand-&gt;setGeometry(QRect(origin,event-&gt;pos()).normalized());

   /*
    QRect Rectangle(origin,event-&gt;pos());
    QPixmap image=QPixmap::grabWidget(this,Rectangle);



    image.save("TEST.png","png"); // same problem here and in mousereleaseevent
*/


}
</code></pre>
<p dir="auto">@<br />
the release event:<br />
@<br />
void FramelessWindow::mouseReleaseEvent(QMouseEvent *event){</p>
<pre><code>    rubberBand-&gt;hide();
    QRect Rectangle(origin,event-&gt;pos());
    QPixmap image=QPixmap::grabWidget(this,Rectangle);
    image.save("TEST.png","png");
close();


}
</code></pre>
<h2>@</h2>
<p dir="auto">Only when I drag from top left to down right it works.</p>
]]></description><link>https://forum.qt.io/topic/41269/solved-about-the-coordinates-of-my-screen-qt</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Apr 2026 23:34:53 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/41269.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 11 May 2014 22:44:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Solved]about the coordinates of my screen. Qt on Mon, 12 May 2014 00:14:17 GMT]]></title><description><![CDATA[<p dir="auto">^</p>
<p dir="auto">Thank you for all your help , I wouldn't have solved the problem in my last post without your help :D</p>
]]></description><link>https://forum.qt.io/post/228155</link><guid isPermaLink="true">https://forum.qt.io/post/228155</guid><dc:creator><![CDATA[Project try]]></dc:creator><pubDate>Mon, 12 May 2014 00:14:17 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved]about the coordinates of my screen. Qt on Sun, 11 May 2014 23:25:37 GMT]]></title><description><![CDATA[<p dir="auto">You need to "normalize":<a href="http://qt-project.org/doc/qt-5/qrect.html#normalized" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5/qrect.html#normalized</a> the rectangle.</p>
<p dir="auto">[EDIT] I see you have found it already :-)</p>
]]></description><link>https://forum.qt.io/post/228154</link><guid isPermaLink="true">https://forum.qt.io/post/228154</guid><dc:creator><![CDATA[andreyc]]></dc:creator><pubDate>Sun, 11 May 2014 23:25:37 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved]about the coordinates of my screen. Qt on Sun, 11 May 2014 23:24:29 GMT]]></title><description><![CDATA[<p dir="auto">Finally figured out why it causes this :D</p>
<p dir="auto">I've just read about the function normalized and it solved it:<br />
@<br />
QPoint a= mapToGlobal(origin);<br />
QPoint b=event-&gt;globalPos();<br />
QRect Rectangle(a,b);<br />
//QPixmap image=QPixmap::grabWidget(this,Rectangle);<br />
QPixmap image=QWidget::grab(Rectangle.normalized());</p>
<pre><code>image.save("TEST.png","png");
</code></pre>
<p dir="auto">@</p>
]]></description><link>https://forum.qt.io/post/228153</link><guid isPermaLink="true">https://forum.qt.io/post/228153</guid><dc:creator><![CDATA[Project try]]></dc:creator><pubDate>Sun, 11 May 2014 23:24:29 GMT</pubDate></item></channel></rss>