Home > Mobile >  QPainter used setWindow text image after conversion
QPainter used setWindow text image after conversion

Time:09-15

Use setWindow conversion before the origin of coordinates is the upper left corner, with setWindow and setViewport converted the origin coordinate in the lower left corner,
This coordinate system is the same as the math,
Question, the converted text image, this how to solve?

CodePudding user response:

This won't solve, just directly in painter, also is no good, most of the GUI framework to the top left corner as a starting point, the transformation need to flip the y axis, the drawing is according to the coordinate system, so the text was upside down, in fact more simple way is you at the time of programming the ordinate y is replaced by (chart height - y) line

 
QPainter painter (this);
Painter. Translate (0, height ());
Painter. Scale (1, 1);
Painter. DrawText (the rect (), Qt: : AlignCenter, "123456");

CodePudding user response:

You this kind of method can be achieved, but I'll paint qpixmap, in the qpixmap qpainter on, this should be first on the qpainter painter. SetWindow (0, height (), width (), 1 * (height ())) set the coordinates to the lower left corner, draw on qpixmap, also set up a time, in this way that have other good method
  •  Tags:  
  • Qt
  • Related