Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Image Popup Animation



  • I'm using PyQt to make a thumbnail image open into a full size image. I've been able to make this happen, but the animation looks all jerky and stupid for some reason. Also, mapToGlobal is giving me the wrong values. The image starts off about 30 pixels away vertically and 15 horizontally. Here's my popup class:

    @
    class ImagePopup(QLabel):
    def init(self, parent):
    super(ImagePopup, self).init(parent)

    self.setScaledContents(True)
    self.setPixmap(parent.pixmap())

    openWidth = parent.width() * 2
    openHeight = parent.height() * 2

    parentPosition = parent.mapToGlobal(parent.pos())
    openX = (parentPosition.x() + (parent.width() / 2) ) - (openWidth / 2)
    openY = (parentPosition.y() + (parent.height() / 2) ) - (openHeight / 2)

    self.openAnimation = QPropertyAnimation(self, "geometry")
    self.openAnimation.setDuration(500)
    self.openAnimation.setStartValue(QRect(parentPosition.x(), parentPosition.y(), parent.width(), parent.height()))
    self.openAnimation.setEndValue(QRect(openX, openY, openWidth, openHeight))
    self.openAnimation.setEasingCurve(QEasingCurve.InOutQuad)

    self.setWindowFlags(Qt.Popup | Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.X11BypassWindowManagerHint)

    def open(self):
    self.openAnimation.start()

    def mousePressEvent(self, ev):
    super(ImagePopup, self).mousePressEvent(ev)

    self.openAnimation.stop()
    self.destroy()
    @

    Thank you for any help. I'm about to give up on this.


Log in to reply