<?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[Draw a head arrow]]></title><description><![CDATA[<p dir="auto">Hello everyone:<br />
First of all thanks for helping me and reading this post.</p>
<p dir="auto">I have some items lines in a scene and now I would like to draw a head arrow in each line.<br />
I have tried this with head arrows as Poligon and then add to the scene like this:</p>
<pre><code>    QPolygonF head_arrow;

for (.....)
{
..................
                   head_arrow &lt;&lt; QPoint((lines_vector[i].x_end)-min_x,max_y-(lines_vector[i].y_end));
                    head_arrow &lt;&lt; QPoint((lines_vector[i].x_end)-min_x-0.01,max_y-lines_vector[i].y_end+0.01*tan(30*3.14/180));
                    head_arrow &lt;&lt; QPoint((lines_vector[i].x_end)-min_x-0.01,max_y-lines_vector[i].y_end-0.01*tan(30*3.14/180));
                    head_arrow &lt;&lt; QPoint((lines_vector[i].x_end)-min_x,max_y-(lines_vector[i].y_end));

                    scene-&gt;addPolygon(head_arrow,black);
................
</code></pre>
<p dir="auto">It compiles fine but the head arrows does not fit like my code...<br />
is there any other way to do that or any ideas to fit my problem?</p>
<p dir="auto">thanks a lot.</p>
<p dir="auto">EDIT:</p>
<p dir="auto">I have tried with Qpaintevent as well like this:</p>
<pre><code>void MainWindow::paintEvent(QPaintEvent *e)
{
    QPainter painter(ui-&gt;graphicsview);
    QPolygonF head_arrow;
    QPen linepen;
    linepen.setWidthF(1);
    linepen.setColor(Qt::red);
    painter.setPen(linepen);

    for (int i=0;i&lt;lines_vector.size();i++)
    {
        head_arrow &lt;&lt; QPoint((lines_vector[i].x_end)-min_x,max_y-(lines_vector[i].y_end));
        head_arrow &lt;&lt; QPoint((lines_vector[i].x_end)-min_x-0.01,max_y-lines_vector[i].y_end+0.01*tan(30*3.14/180));
        head_arrow &lt;&lt; QPoint((lines_vector[i].x_end)-min_x-0.01,max_y-lines_vector[i].y_end-0.01*tan(30*3.14/180));
        head_arrow &lt;&lt; QPoint((lines_vector[i].x_end)-min_x,max_y-(lines_vector[i].y_end));
        painter.drawPolygon(head_arrow);
    }
}
</code></pre>
<p dir="auto">It compiles fine but it says errors:<br />
QWidget::paintEngine: Should no longer be called<br />
QPainter::begin: Paint device returned engine == 0, type: 1<br />
QPainter::setPen: Painter not active</p>
<p dir="auto">And if I change this line    QPainter painter(ui-&gt;graphicsview);  to     QPainter painter(this);<br />
it has not errors but it does not paint anything...</p>
]]></description><link>https://forum.qt.io/topic/66662/draw-a-head-arrow</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 01:40:00 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/66662.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 03 May 2016 07:52:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Draw a head arrow on Tue, 03 May 2016 08:39:33 GMT]]></title><description><![CDATA[<p dir="auto">The sample<br />
<a href="http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html</a><br />
has arrow class.<br />
Maybe it can provide inspiration.</p>
]]></description><link>https://forum.qt.io/post/325335</link><guid isPermaLink="true">https://forum.qt.io/post/325335</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Tue, 03 May 2016 08:39:33 GMT</pubDate></item></channel></rss>