PySide Python3 Properties problem
Hi! I’m new to Pyside and I was looking at the basic tutorials (http://qt-project.org/wiki/Using_Qt_Properties_in_PySide). I have found out, that the Properties does not work in Python3 as expected. Please take a look at:
- def __init__(self,startval=42):
- self.ppval = startval
- def readPP(self):
- return self.ppval
- def setPP(self,val):
- self.ppval = val
- pp = Property(int, readPP, setPP)
- obj = MyObject()
- obj.pp = 47
- print (obj.pp)
In Python3 you get:
- <Property object at 0x2f39948>
as a result, and it should return 47.
5 replies
I don’t have the answer, but found the question interesting.
Your example should be more complete. I found that Property is defined by PySide. So you should add to your example:
But calling the standard Python property works:
- pp = property(readPP, setPP)
I am left wondering what the documentation means “simultaneously behave both as Qt and Python properties”? What does “Qt property” give you?
Could it have something to do with not embedding in a larger Qt application where signals are initialized?
Indn: aren’t you missing the point: you should be able to access the value of a property by simply referring to the attribute ‘obj.pp’, without needing to call the getter method ‘obj.readPP().’ Its related to “Command Query Separation Principle”: a query should not need call syntax (with ‘()’) even if some computation (getter method) is involved.
You must log in to post a reply. Not a member yet? Register here!

