QPainter is a class in the Qt C++ library that enables the painting of graphical objects onto widgets and graphics views.
QPainter::translate() is a method in the QPainter class that allows you to translate the coordinate system of the painter, effectively moving the origin to a new point. This can be useful when you want to draw objects in a specific location.
For example, let's say you want to draw a red circle in the top-left corner of a widget. You could use the following code:
```c++
QPainter painter(this);
painter.setBrush(Qt::red);
painter.translate(10, 10);
painter.drawEllipse(QRectF(0, 0, 50, 50));
```
The first line creates a new QPainter object with a pointer to the current widget. The second line sets the brush color to red. The third line translates the coordinate system by 10 pixels in the x and y directions. The last line draws an ellipse with a rectangular bounding box of size 50x50, but since we've translated by (10, 10), the top-left corner of the ellipse will be at (10, 10) relative to the widget.
This code example uses Qt library package.
C++ (Cpp) QPainter::translate - 30 examples found. These are the top rated real world C++ (Cpp) examples of QPainter::translate extracted from open source projects. You can rate examples to help us improve the quality of examples.