C++ and Qt - Problem with 2D graphics -


Mission: Automatically clipping on one clip, add two lines slightly different colors on one bit and two.

So, what I'm doing is create inherited classes from the QGraphicsView GraphWidget Create QGraphicsScene members 2 Create QPainterPath example, and add them to GraphicsCissen.

Then, I finally call graphWidget.Redraw (), where for both instances call QPainterPath.lineTo (). And I hope that the presence of that line of graphics, but it's not.

I'm tired of reading Qt's doctor and forum what am I doing?

We have to know more, will not we? Does the window appear at all? What lines are not ready? If you want, try this sample code :) Edit: updated to update

  #include ... class QupdatingPathItem: public QGraphicsPathItem {zero advance (int step) {if (step == 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 []) {Q Application 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-> Connect (timer, signal (timeout ()), & amp; s, slot (advance ()); Timer-> (1000) start; Back a.exec (); }  

You should do something like this:

Meh ...

The path in any QGraphicsPathItem can be fixed later on. If you want to avoid the display hit due to all the path copy of the original Painter Path anywhere (I'm not sure if QPainterPath is shared with each other ...)

  QPainterPath p = gPath Path (); P.lineTo (0, 42); GPath.setPath (P);  

animation

It seems that you are trying to update some type of animation / fly. QT has the entire framework for this in the simplest form, you can sub-class QGraphicsPathItem, to complete your advance (slot) again, automatically get the next point from the speed, only one thing to do is to do this The frequency will be calling s.advance ().


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -