rubenvb

25th September 2009, 14:26

Dear all,

I'm trying to write a simple QWidget class that draws the data in a QPolygonF (=QVector<QPointF>). What I am trying to do is create a QTransform that holds the appropriate coordinate transformation info to transform from a real cartesian coordinate system to the pixel integer coordinate system. The purpose of this is so that I can use from within my QWidget:

QPainter p(this);

p.setWorldTransform( QTransform( /*appropriate values*/ ) );

p.drawLine( /*coordinates in real/double values);

This should be possible, but my calculated transformation does not work as intended :(.

I have tried this with following assumption:

drawLine converts the parameters by multiplying the values with the matrix, which leads to the (rounded off) integer values used to draw the line in the viewed area.

Then the resize operation would only require adapting the matrix to the new height and width and repainting the scene.

This does not happen :(, could someone with more knowledge of QGraphicsview help please. Thanks!

I'm trying to write a simple QWidget class that draws the data in a QPolygonF (=QVector<QPointF>). What I am trying to do is create a QTransform that holds the appropriate coordinate transformation info to transform from a real cartesian coordinate system to the pixel integer coordinate system. The purpose of this is so that I can use from within my QWidget:

QPainter p(this);

p.setWorldTransform( QTransform( /*appropriate values*/ ) );

p.drawLine( /*coordinates in real/double values);

This should be possible, but my calculated transformation does not work as intended :(.

I have tried this with following assumption:

drawLine converts the parameters by multiplying the values with the matrix, which leads to the (rounded off) integer values used to draw the line in the viewed area.

Then the resize operation would only require adapting the matrix to the new height and width and repainting the scene.

This does not happen :(, could someone with more knowledge of QGraphicsview help please. Thanks!