Draw text and numbers in dot matrix format
-
-
@giusdbg said in Draw text and numbers in dot matrix format:
should it draw a one point line or draw nothing?
Nothing, I would say. You move the painter to (22, 7) ( = make this the current position) and then start to draw a "line" from (22, 7) to (22, 7)
Having to draw some text and numbers in graphic form (see below for an example), is there an easy way to do it?
What about the
QGraphicsView
framework? -
@Pl45m4 Yes, but if it works like this how do you draw a point?
My problem is that I converted a text draw from qt3 to qt4, and it all works, the dimensions are all right (not a pixel less), it just doesn't draw a one point line.
I printed the values used in moveTo and lineTo, and they are identical.
Ignore the abstruse calculations,
qt3
void QLcd::drawSegment(QPainter *p,const int *c, int x, int y, int w, int h) { h--; p->moveTo( x+(c[0]*w)/2 , y+(c[1]*h)/4 ); c+= 2; do { p->lineTo( x+(c[0]*w)/2 , y+(c[1]*h)/4 ); c+= 2; } while(*c>=0); }
qt4
void QLcd::drawSegment(QPainter *p,const int *c, int x, int y, int w, int h) { h--; QPainterPath path; path.moveTo (x+(c[0]*w)/2 , y+(c[1]*h)/4); c+= 2; do { path.lineTo( x+(c[0]*w)/2 , y+(c[1]*h)/4 ); c+= 2; } while(*c>=0); p->drawPath( path ); }
-
@mpergand @Pl45m4 Works, thanks.
But I still had to do a trick, when the start and end point is the same, sum 0.1 to the end point..
I'll try the framework and font suggestions in the project review phase, which I definitely need to do.
(The qt4 port must work fine first, probably in the qt5/6 port). -