void ImageShow::paintEvent(QPaintEvent *){
QPainter painter(this);
QImage img(":/images/1-NoView.png");
if(havePng)
{
if (m_image.size().width() <= 0)
return;
QImage img = m_image.scaled(this->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
painter.drawImage(QPoint(0, 0), img);
//直接加到图片上
painter.setPen(Qt::blue);
painter.setFont(QFont("Arial",16));
painter.drawText(QRect(0,0,this->width(),this->height()-15),Qt::AlignRight | Qt::AlignBottom,CameraName);
//悬浮在图片上面
//QLabel *label = new QLabel(this);
//label->setText(QStringLiteral(" 机智 "));
//label->setStyleSheet("QLabel { background-color : transparent; }");
//label->move(100,100);
//label->show();
}else {
int x = this->geometry().x();
int y = this->geometry().y();
painter.drawImage(QPoint(x, y-30),img.scaled(this->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
}
02-24
3535