直接上code
void paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
QRect rect0 = QRect(0,0,500,500);painter.drawRect(rect0);QRect rectB = QRect(-1,-1,501,501);painter.drawRect(rectB);//画三角形QLine line1 = QLine(QPoint(250.0f,80.0f),QPoint(400.0f,350.0f));QLine line2 = QLine(QPoint(250.0f,80.0f),QPoint(100.0f,350.0f));QLine line3 = QLine(QPoint(100.0f,350.0f),QPoint(400.0f,350.0f));painter.drawLine(line1);painter.drawLine(line2);painter.drawLine(line3);painter.drawText(245,75,"PD");//画刻度QLine Graduation1_1 = QLine(QPoint(115.0f,324.0f),QPoint(125.0f,324.0f));QLine Graduation1_2 = QLine(QPoint(129.0f,297.0f),QPoint(139.0f,297.0f));QLine Graduation1_3 = QLine(QPoint(145.0f,270.0f),QPoint(155.0f,270.0f));QLine Graduation1_4 = QLine(158.0f,243.0f,168.0f,243.0f);QLine Graduation1_5