How do I animate a position change with QPropertyAnimation while using a layout method?

1.1k Views Asked by At

So basically what I am trying to do is animate a widget moving, the start point being (0,0) or somewhere on the side of the parent window, and then the end point being where the widget is actually positioned on the parent window. But I am using a layout method, QGridLayout to be specific, so i cannot just change the geometry like you normally would from my understanding. Here is what a tried so far.

    print ("POS: ", self.Play_label.pos())

    geometry_play = self.Play_label.geometry()
    print ("mapp: ", self.Play_label.mapToGlobal(QPoint(0,0)))

    print ("play geo: ", geometry_play)

    self.animation = QPropertyAnimation(self.Play_label, b"geometry")

    self.animation.setDuration(3000)
    self.animation.setStartValue(QRect(0,0,150,150))
    self.animation.setEndValue(geometry_play)
    #print ("Value: ", self.animation.currentValue())
    #self.animation.valueChanged.connect(self.Play_label.changeImageSize)
    #self.animation.setTargetObject(self.Play_label)
    self.animation.start()

But the label that I created always has its x and y coordinates being (0,0), is this because I am using a layout method? Even if I attempt to print out the position using the .pos() method it always returns (0,0).

Is there any simple way to animate this change? I understand I can change the 2nd parameter of the animation to something other than geometry but i cannot figure out what i would change it to in my case. Please any helps would be much appreciated been trying to figure this out for days now.

0

There are 0 best solutions below