<?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[Repaint() function paints only last point!!]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/void">@<bdi>void</bdi></a> Widget::paintEvent(QPaintEvent *eve){<br />
QPainter p(this);<br />
QPen pen(Qt::white,1,Qt::SolidLine);<br />
p.setPen(pen);<br />
if(f==1){<br />
qDebug()&lt;&lt;x;<br />
p.drawPoint(x,y);<br />
f=0;<br />
}</p>
<p dir="auto">}</p>
<p dir="auto">void Widget::func()<br />
{<br />
for(int i=0;i&lt;100;i++){<br />
f=1;<br />
x++;<br />
repaint();<br />
qDebug()&lt;&lt;x;</p>
<pre><code>}
</code></pre>
<p dir="auto">}<br />
@</p>
]]></description><link>https://forum.qt.io/topic/39829/repaint-function-paints-only-last-point</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 21:02:31 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/39829.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 Apr 2014 04:39:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Repaint() function paints only last point!! on Thu, 03 Apr 2014 19:33:53 GMT]]></title><description><![CDATA[<p dir="auto">Breaking a big function in smaller pieces doesn't mean you need to redo your logic. If your teacher was happy with your first implementation, just keep it and isolate each part</p>
]]></description><link>https://forum.qt.io/post/221679</link><guid isPermaLink="true">https://forum.qt.io/post/221679</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 03 Apr 2014 19:33:53 GMT</pubDate></item><item><title><![CDATA[Reply to Repaint() function paints only last point!! on Thu, 03 Apr 2014 18:51:55 GMT]]></title><description><![CDATA[<p dir="auto">Hi, repaint() is usually called when you want to clean or refresh your widget's screen area, what I mean: you call "erase screen" 100 times and drawPoint() 100 times :-)</p>
<p dir="auto">Best is to do what SGaist suggests,use a QTimer.</p>
<p dir="auto">Or you can change your code in Widget::paintEvent() so that first time it's called it draws just one point; then next time it's called, redraw previous point and one more, next time draw 3 points etc.</p>
]]></description><link>https://forum.qt.io/post/221673</link><guid isPermaLink="true">https://forum.qt.io/post/221673</guid><dc:creator><![CDATA[hskoglund]]></dc:creator><pubDate>Thu, 03 Apr 2014 18:51:55 GMT</pubDate></item><item><title><![CDATA[Reply to Repaint() function paints only last point!! on Thu, 03 Apr 2014 10:31:32 GMT]]></title><description><![CDATA[<p dir="auto">The actual func() is line drawing algorithms,dda()<br />
And bresenham(). I had written these functions in paintevent itself but the teacher told me to make separate functions.<br />
Hence  i had to call repaint().<br />
The algorithm increments or decrements the global variables x and y according to the algorithm and i expect repaint to draw the points.<br />
Hope i made my point clear.<br />
Thank you</p>
]]></description><link>https://forum.qt.io/post/221588</link><guid isPermaLink="true">https://forum.qt.io/post/221588</guid><dc:creator><![CDATA[onkar]]></dc:creator><pubDate>Thu, 03 Apr 2014 10:31:32 GMT</pubDate></item><item><title><![CDATA[Reply to Repaint() function paints only last point!! on Thu, 03 Apr 2014 07:12:07 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">As <em>Johan</em> said, calling repaint like that is a bad idea. If you want to animate the painting you should rather use e.g. a QTimer.</p>
<p dir="auto">Also, you have to pay attention on the value of x, just incrementing it will make it larger than your widget.</p>
]]></description><link>https://forum.qt.io/post/221542</link><guid isPermaLink="true">https://forum.qt.io/post/221542</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 03 Apr 2014 07:12:07 GMT</pubDate></item><item><title><![CDATA[Reply to Repaint() function paints only last point!! on Thu, 03 Apr 2014 05:55:58 GMT]]></title><description><![CDATA[<p dir="auto">Hello and welcome to the forum!</p>
<p dir="auto">AFAIK you should not call paintEvent so often. The loop on your points you have in your Widget::func method should rather be in the Widget::paintEvent method. But I have no clue if this will solve your problem.</p>
]]></description><link>https://forum.qt.io/post/221528</link><guid isPermaLink="true">https://forum.qt.io/post/221528</guid><dc:creator><![CDATA[JohanSolo]]></dc:creator><pubDate>Thu, 03 Apr 2014 05:55:58 GMT</pubDate></item></channel></rss>