Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We need to know more, what does not happen? Does the window appear at all? Are the lines not drawn? In the meantime try out this sample code if you want :) Edit: updated to show updating.</p> <pre><code>#include ... class QUpdatingPathItem : public QGraphicsPathItem { void advance(int phase) { if (phase == 0) return; int x = abs(rand()) % 100; int y = abs(rand()) % 100; QPainterPath p = path(); p.lineTo(x, y); setPath(p); } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); QGraphicsScene s; QGraphicsView v(&amp;s); QUpdatingPathItem item; item.setPen(QPen(QColor("red"))); s.addItem(&amp;item); v.show(); QTimer *timer = new QTimer(&amp;s); timer-&gt;connect(timer, SIGNAL(timeout()), &amp;s, SLOT(advance())); timer-&gt;start(1000); return a.exec(); } </code></pre> <p>You should get something like this:</p> <p><img src="https://imgur.com/6kC2Y.png" alt="meh..."></p> <p>The path in any <code>QGraphicsPathItem</code> can of course be updated later. You might want to keep the original painter path somewhere to avoid performance hit caused by all the path copying (I'm not sure if QPainterPath is implicitly shared...)</p> <pre><code>QPainterPath p = gPath.path(); p.lineTo(0, 42); gPath.setPath(p); </code></pre> <h1>Animation</h1> <p>It seems that you're trying to do some sort of animation/on-the-fly updating. There is entire framework for this in Qt. In the simplest form you can subclass QGraphicsPathItem, reimplement its advance() slot to automatically fetch next point from motion. The only thing left to do then would be calling s.advance() with the required frequency.</p> <p><a href="http://doc.trolltech.com/4.5/qgraphicsscene.html#advance" rel="nofollow noreferrer">http://doc.trolltech.com/4.5/qgraphicsscene.html#advance</a> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload