29 lines
577 B
C++
29 lines
577 B
C++
#include "stdafx.h"
|
|
#include "AspectRatioLabel.h"
|
|
|
|
AspectRatioLabel::AspectRatioLabel(QWidget* parent)
|
|
: QLabel(parent)
|
|
{
|
|
setAlignment(Qt::AlignCenter);
|
|
}
|
|
|
|
void AspectRatioLabel::setOriginalPixmap(const QPixmap& pixmap)
|
|
{
|
|
m_originalPixmap = pixmap;
|
|
updateScaledPixmap();
|
|
}
|
|
|
|
void AspectRatioLabel::resizeEvent(QResizeEvent* event)
|
|
{
|
|
QLabel::resizeEvent(event);
|
|
updateScaledPixmap();
|
|
}
|
|
|
|
void AspectRatioLabel::updateScaledPixmap()
|
|
{
|
|
if (m_originalPixmap.isNull())
|
|
return;
|
|
|
|
setPixmap(m_originalPixmap.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
|
}
|