<?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[QPaintEvent]]></title><description><![CDATA[<p dir="auto">Hi, am trying to draw points on my image with different colors.<br />
he is the code</p>
<p dir="auto">#include "mainwindow.h"<br />
#include "ui_mainwindow.h"<br />
#include&lt;iostream&gt;</p>
<p dir="auto">using namespace std;</p>
<p dir="auto">MainWindow::MainWindow(QWidget *parent)<br />
: QMainWindow(parent),<br />
ui(new Ui::MainWindow)</p>
<p dir="auto">{<br />
ui-&gt;setupUi(this);</p>
<p dir="auto">}</p>
<p dir="auto">MainWindow::~MainWindow()<br />
{<br />
delete ui;<br />
}</p>
<p dir="auto">/<em>this function get the value of lat</em>/<br />
double MainWindow::getLat(double k)<br />
{<br />
double value=0;</p>
<pre><code>if(k&lt;=505&amp;&amp;k&gt;=0)
     { value=90-k*(18/101);}

if(k&gt;505&amp;&amp;k&lt;=1010)
      {value=k*(18/101)-90;}
return value;
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void MainWindow:: paintEvent(QPaintEvent *event)<br />
{</p>
<p dir="auto">/*here i plot my image first */</p>
<pre><code>QImage image;
image.load("C:/Users/hp/Documents/Qt/untitled2/earthh.jpg");
QPainter imagePainter(this);
imagePainter.begin(this);
imagePainter.drawImage(QPoint(0, 0), image);
imagePainter.end();
</code></pre>
<p dir="auto">/<em>then here i plot my points</em>/</p>
<pre><code>QPainterPath dotCircle;
double lat=0;

for ( double i=0;i&lt;=1920;i+=50)
{
    for(double j=0;j&lt;1000;j+=50)
    {

         dotCircle.addEllipse(QPoint(i,j),3,3);
         QPainter ellipsePathPainter;
         ellipsePathPainter.begin(this);
         ellipsePathPainter.setPen(QPen(Qt::transparent,1, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin));

        double k=lat;
        lat=qDegreesToRadians(getLat(j)); //the problem is here this line is only getting executed twice when j&lt;550 and when j&gt;505 

        double alt=0.0;
        double  champs=(U*M*sqrt(4-3*pow(cos(lat),2)))/(4*M_PI*pow(alt+Re,3))*1000000;

        if(champs&gt;=45&amp;&amp;champs&lt;60)
                 {ellipsePathPainter.setBrush(Qt::green);}
        else if(champs&gt;=35&amp;&amp;champs&lt;45)
                 { ellipsePathPainter.setBrush(Qt::yellow);}
        else if(champs&gt;=30&amp;&amp;champs&lt;35)
                 { ellipsePathPainter.setBrush(Qt::magenta);}
        else
                { ellipsePathPainter.setBrush(Qt::red);}

        ellipsePathPainter.drawPath(dotCircle);
        ellipsePathPainter.end();

        }
}
</code></pre>
<p dir="auto">}</p>
<p dir="auto">as the outcome the points are  plotted all  with the same colors because my function getlat() is only getting called twice .</p>
]]></description><link>https://forum.qt.io/topic/113081/qpaintevent</link><generator>RSS for Node</generator><lastBuildDate>Tue, 09 Jun 2026 14:24:21 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/113081.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 30 Mar 2020 12:51:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QPaintEvent on Mon, 30 Mar 2020 23:55:52 GMT]]></title><description><![CDATA[<p dir="auto">problem solved</p>
]]></description><link>https://forum.qt.io/post/585691</link><guid isPermaLink="true">https://forum.qt.io/post/585691</guid><dc:creator><![CDATA[kingJulian]]></dc:creator><pubDate>Mon, 30 Mar 2020 23:55:52 GMT</pubDate></item><item><title><![CDATA[Reply to QPaintEvent on Mon, 30 Mar 2020 14:31:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> i printed the value of lat and  the outcome was 1.507 and -1.507 multiple times</p>
]]></description><link>https://forum.qt.io/post/585580</link><guid isPermaLink="true">https://forum.qt.io/post/585580</guid><dc:creator><![CDATA[kingJulian]]></dc:creator><pubDate>Mon, 30 Mar 2020 14:31:05 GMT</pubDate></item><item><title><![CDATA[Reply to QPaintEvent on Mon, 30 Mar 2020 12:57:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kingjulian">@<bdi>kingJulian</bdi></a> said in <a href="/post/585559">QPaintEvent</a>:</p>
<blockquote>
<p dir="auto">because my function getlat() is only getting called twice</p>
</blockquote>
<p dir="auto">How did you check this?</p>
]]></description><link>https://forum.qt.io/post/585561</link><guid isPermaLink="true">https://forum.qt.io/post/585561</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Mon, 30 Mar 2020 12:57:45 GMT</pubDate></item></channel></rss>