void ShowImage::paintEvent(QPaintEvent *event)
{
if(ui->stackedWidget->currentIndex() == 0){
QPainter painter(this);
/painter.begin(this);//会出现QPainter::begin: Painter already active
painter.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::RoundCap));
painter.drawLine(0, 28, this->width(), 28);
painter.drawLine(1006, 28, 1006, this->height());
painter.setPen(QPen(Qt::red, 2, Qt::SolidLine, Qt::RoundCap));
painter.drawLine(60, 254, 1006, 254);//194
painter.drawLine(60, 452, 1006, 452);//392
painter.drawLine(60, 648, 1006, 648);//588
painter.drawLine(60, 844, 1006, 844);//
painter.end();
}else if(ui->stackedWidget->currentIndex() == 1){
QPainter painter(this);
painter.begin(this);
painter.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::RoundCap));
painter.drawLine(0, 28, this->width(), 28);
painter.drawLine(1006, 28, 1006, this->height());//1030
painter.end();
}
}