[Qt-interest] Sin wave with using QGraphicsScene/QGraphicsView

Dave Smith dave at thesmithfam.org
Thu Dec 3 20:09:51 CET 2009


Kari Laine wrote:
> Hi All,
>
> I turn to you again. I would really need a little example how to draw
> sin wave with QGraphicsScene/QGraphicsView . I am now going through an
> example diagramscene from QT-examples and I am not able to undestand
> where the QPainter is initialized. And example contains a lot of code
> - I would need a little example to stop my head spinning.
>
> As told I am working on a GPL-project.

You don't usually need to initialize a QPainter with QGraphcisView. You 
just sub-class a QGraphicsItem class and reimplement the paint() method. 
One of the arguments to paint() is a QPainter*, which you use to paint 
to your graphics item.

You might want to forget about QPainter and just use a 
QGraphicsPathItem, where each point in the path is a point along your 
(discreet) sine wave.

--Dave



More information about the Qt-interest-old mailing list