【代码】
void MainWindow::paintEvent(QPaintEvent*)
{
QPainter p(this);
QRect r;
p.setPen(Qt::red);
p.drawText(20, 80, 120, 20, 0, "Hello World!", &r);
//
}
【结果】
QPoint 点的位置坐标
QPoint::QPoint(int xpos, int ypos)
Constructs a point with the given coordinates (xpos, ypos).
See also setX() and setY().
[static] int QPoint::dotProduct(const QPoint &p1, const QPoint &p2)
示例:
QPoint p( 3, 7);
QPoint q(-1, 4);
int lengthSquared = QPoint::dotProduct(p, q); // lengthSquared becomes 25
Returns the dot product of p1 and p2. 返回值,点 p1,p2 的距离
【拓展阅读】
1、paintEvent 实现绘制钟表的官方例子http