既上一片的实现QPushButton定制功能后,在此基础上增加可定制进度条功能
void ProgressButton::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
static QImage img;
if (m_currentImage.isNull()) {
return;
}
QSize size = m_currentImage.size();
m_currentImage = m_currentImage.scaled(rect().width(), rect().height()
, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
if (img.isNull() || img.width() != m_currentImage.width() || img.height() != m_currentImage.width()) {
img = QImage(m_currentImage.size(), QImage::Format_RGBA8888);
}
&nbs