You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
813 B

# coding:utf-8
from PySide6.QtCore import Qt
from PySide6.QtGui import QPainter, QPixmap
from PySide6.QtWidgets import QLabel
class PixmapLabel(QLabel):
""" Label for high dpi pixmap """
def __init__(self, parent=None):
super().__init__(parent)
self.__pixmap = QPixmap()
def setPixmap(self, pixmap: QPixmap):
self.__pixmap = pixmap
self.setFixedSize(pixmap.size())
self.update()
def pixmap(self):
return self.__pixmap
def paintEvent(self, e):
if self.__pixmap.isNull():
return
painter = QPainter(self)
painter.setRenderHints(QPainter.Antialiasing |
QPainter.SmoothPixmapTransform)
painter.setPen(Qt.NoPen)
painter.drawPixmap(self.rect(), self.__pixmap)