mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 12:52:04 +08:00
SVG render error in Qt6, so fallback to use PNG; add CustomLabel for render PNG not blurry with HIDPI Log: add PNG resources for tag icons; add CustomLabel class for PNG rendering
26 lines
588 B
C++
26 lines
588 B
C++
#include "customlabel.h"
|
|
|
|
#include <QGuiApplication>
|
|
|
|
CustomLabel::CustomLabel(QWidget *parent,
|
|
Qt::WindowFlags f)
|
|
: QLabel(parent, f)
|
|
{
|
|
}
|
|
|
|
QPixmap CustomLabel::pixmap() const
|
|
{
|
|
return QLabel::pixmap();
|
|
}
|
|
|
|
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);
|
|
}
|