Hello, does someone has the Python (PyQt5) version of the BlurPicker example from the Qt Crator 5. Itried to convert it to Python, but I cant get the right solution . This is my code:
QPropertyAnimation: you're trying to animate a non-existing property index of your QObject
QPropertyAnimation::updateState (index, BlurPicker, ): starting an animation without start value
import math from PyQt5.QtCore import (QEasingCurve, QPointF, QPropertyAnimation, QAbstractAnimation, Qt) from PyQt5.QtGui import QPixmap, QPainter from PyQt5.QtWidgets import (QApplication, QGraphicsScene, QGraphicsView, QGraphicsPixmapItem, QFrame) class BlurPicker(QGraphicsView): def __init__(self, parent=None): super(BlurPicker, self).__init__(parent) self.m_index = 0.0 self.scene = QGraphicsScene() self.m_icons = [] self.names = [] self.m_animation = QPropertyAnimation(self, b'index') print("bb") #self.setScene(self.scene) self.setupScene() self.setIndex(0) self.m_animation.setDuration(400) self.m_animation.setEasingCurve(QEasingCurve.InOutSine) self.setRenderHint(QPainter.Antialiasing) self.setFrameStyle(QFrame.NoFrame) def index(self): print("aa") return self.m_index def setIndex(self,index): self.m_index = index print(self.m_index) self.baseline = 0 print(len(self.m_icons)) for i in range(len(self.m_icons)): print("ii") #icon = QGraphicsItem() icon = self.m_icons self.a = ((i + self.m_index)*2*math.pi/ len(self.m_icons)) xs = 170 * math.sin(self.a) ys = 170 * math.cos(self.a) pos = QPointF(xs, ys) icon.setPos(pos) # baseline = max(baseline, ys) # icon.setBaseLine(baseline) self.scene.update() def setupScene(self): self.scene.setSceneRect(-200, -120, 400, 240) names = [] names.append("img.png") names.append('img.png') names.append('img.png') names.append('img.png') names.append('img.png') names.append('img.png') names.append('img.png') for i in names: pixmap = QPixmap(i) icon = QGraphicsPixmapItem() self.scene.addPixmap(pixmap) icon.setZValue(0) self.m_icons.append(icon) print(len(self.m_icons)) def keyPressEvent(self, e): delta = 0 if e.key() == Qt.Key_Left: delta = -1 elif e.key() == Qt.Key_Right: delta = 1 if self.m_animation.state() == QAbstractAnimation.Stopped and delta: self.m_animation.setEndValue(self.m_index + delta) print("wwww") self.m_animation.start() e.accept() if __name__== '__main__': import sys app = QApplication(sys.argv) picker = BlurPicker() picker.setWindowTitle("Picker") picker.resize(640, 480) picker.show() sys.exit(app.exec_())I am getting error:
QPropertyAnimation: you're trying to animate a non-existing property index of your QObject
QPropertyAnimation::updateState (index, BlurPicker, ): starting an animation without start value