PyQt窗口阴影
两种方式
贴图
这个写的挺好 PyQt制造窗口阴影,想说爱你不容易
代码画
话不多说, 直接贴代码
from PyQt5.QtGui import QFont, QPainterPath, QPainter, QColor, QBrush, QPen
class MyWindow(object):
def __init__(self):
pass
def paintEvent(self, event):
m = 5
path = QPainterPath()
path.setFillRule(Qt.WindingFill)
path.addRect(m, m, self.width() - m * 2, self.height() - m * 2)
painter = QPainter(self)
painter.fillPath(path, QBrush(Qt.white))
color = QColor(111, 111, 111, 30)
for i in range(m):
path = QPainterPath()
path.setFillRule(Qt.WindingFill)
path.addRoundedRect(m - i, m - i, self.width() - (m - i) * 2, self.height() - (m - i) * 2, 1, 1)
Alpha_value = int(67 - math.sqrt(i) * 30)
color.setAlpha(Alpha_value)
painter.setPen(QPen(color, 1, Qt.SolidLine))
painter.drawRoundedRect(QRect(m - i, m - i, self.width() - (m - i) * 2, self.height() - (m - i) * 2), 0, 0)
|