Good evening.
I am working on an application with PyQt. A colleague shared the following instruction self.shadow.BlurHint(QGraphicsBlurEffect.PerformanceHint)
. This is to improve the performance of the application when executing the Blur effect.
How can I check that it works?
Here I leave the code that I have done so far. and as a question, How I can move the position of the DropShadow effect , that is to say so that it is on the side of the main window.
Code:
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication ,QLabel, QGraphicsEffect, QVBoxLayout, QGraphicsDropShadowEffect, QGraphicsBlurEffect
from PyQt5 import uic
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5 import QtGui
class Pinricpal(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.resize(600,400)
self.shadow = QGraphicsBlurEffect(self) #Efecto blur
self.shadow.setBlurRadius(25)
self.shadow.BlurHint(QGraphicsBlurEffect.PerformanceHint) #Instrucción que desconozco su funcionamiento
self.setWindowFlags(Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_NoSystemBackground, True)
self.setAttribute(Qt.WA_TranslucentBackground, True)
self.sombra = QGraphicsDropShadowEffect() #Efecto de Sombra al que deseo cambiar la posición.
self.sombra.setBlurRadius(12)
self.sombra.setColor(QColor(33,0,248))
self.sombra.setOffset(2,2)
self.setGraphicsEffect(self.shadow)
self.setGraphicsEffect(self.sombra)
def paintEvent(self, event=None):
painter = QPainter(self)
painter.setOpacity(0.7)
painter.setBrush(QColor(168,34,3))
painter.setPen(QColor(168,34,3))
painter.drawRect(self.rect())
def mousePressEvent(self,event):
if event.button() == Qt.LeftButton:
self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
def mouseMoveEvent(self,event):
if event.buttons() == Qt.LeftButton:
self.move(event.globalPos() - self.dragPosition)
app = QApplication([])
principal = Pinricpal()
principal.show()
app.exec_()