重写paintEvent事件,代码如下 void xx::paintEvent(QPaintEvent *event){ QPainter painter(this); //绘制x,y轴,_maxWidth为y轴边距 painter.drawLine(QPoint(_maxWidth,),QPoint(width(),)); painter.drawLine(QPoint(_maxWidth, ), QPoint(_maxWidth,height())); //绘制刻度,_maxMinutes为…