Hello everyone,

I've assigned a stylesheet to a button. How would I go about animating the margins? I figure the first step is to retrieve the current margin, since that's what I want to animate to. I can't figure it out though...

Qt Code:
  1. from PyQt5 import QtWidgets
  2. QtWidgets.QApplication([])
  3. b = QtWidgets.QPushButton()
  4. b.setStyleSheet("margin: 15px")
  5. b.contentsMargins().top() #is 0, should be 15
To copy to clipboard, switch view to plain text mode 
The final line produces 0 instead of the expected value of 15.

Qt Code:
  1. b.style().subElementRect(QtWidgets.QStyle.SE_PushButtonFocusRect, QtWidgets.QStyleOptionButton())
  2. b.style().subElementRect(QtWidgets.QStyle.SE_PushButtonFocusRect, QtWidgets.QStyleOptionButton(), b)
To copy to clipboard, switch view to plain text mode 
Carrying on, both these lines then print "Segmentation fault" and exit Python. They didn't return anything particularly sensible in my actual app anyway.

Does anyone have any suggestions? I'm trying to make a little 'slide-in' effect for my menu, but I want the buttons to always be clickable even when they haven't slid in yet. I was planning to do it by adjusting the margin-left from my menu width to the original value of margin-left.

Thanks,
–DDR