mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-15 21:32:05 +08:00
26 lines
630 B
C++
26 lines
630 B
C++
#include "customlabel.h"
|
|
|
|
#include <QGuiApplication>
|
|
|
|
CustomLabel::CustomLabel(QWidget *parent,
|
|
Qt::WindowFlags f)
|
|
: QLabel(parent, f)
|
|
{
|
|
}
|
|
|
|
QPixmap CustomLabel::pixmap() const
|
|
{
|
|
const QPixmap* p = QLabel::pixmap();
|
|
return p ? *p : QPixmap();
|
|
}
|
|
|
|
void CustomLabel::setPixmap(const QPixmap &pixmap)
|
|
{
|
|
QPixmap _pixmap = pixmap;
|
|
_pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
|
|
_pixmap = _pixmap.scaled(size() * _pixmap.devicePixelRatio(),
|
|
Qt::KeepAspectRatio,
|
|
Qt::SmoothTransformation);
|
|
|
|
QLabel::setPixmap(_pixmap);
|
|
} |