QPainter painter(&img); QPen pen; pen.setWidth(6); pen.setColor(Qt::green); // 设置画笔为黄色 painter.setPen(pen); // 设置画笔 painter.setFont(QFont("Arial",20)); QRectF rect1(boxes[0].x1,boxes[0].y1,50,50); painter.drawText(rect1,QString("ZKL"));
注意Rect和QRect和QrectF的区别