Star Delegate Example error in python 3.7
-
I've set up the star delegate example, with runs fine under python 2.7 but under 3.7 running into:
Traceback (most recent call last): File "Z:\repos\qtPlayGround\QStyledItemDelegate_Start_Example\starEditor.py", line 25, in sizeHint return self.starRating.sizeHint() AttributeError: 'StarEditor' object has no attribute 'starRating'
I saw that Python 3 only has new-style classes but is there something that needs to change in the StarEditor class? I'm a bit lost as everything looks fine.
Cheers
start delegate files:
https://doc.qt.io/qtforpython/pyside-examples/pyside2examples-widgets-itemviews-stardelegate-example.html#pyside2-qtwidgets-star-delegate-example -
Hi,
How are you running the code exactly ?
I see where the issue is but I'd like to know how you trigger it.
-
Then something else must be off.
In any case, add
from starrating import StarRating
Before the the StarEditor class declaration and then
self.starRating = StarRating()
in its constructor.
A fix to the example has been submitted.
-
No I don't.
I checked with with Python 3.7.6 and the example runs without my change because of how python works and the sequence of actions that will trigger the use of that attribute. The starRating attribute should have been set prior to being used in any case so there might be something different on your system but I don't know what it is.