Okay, I think I've figured it out. I remember the docs mentioned 'user property' but I glossed over it. Turns out I didn't understand what a QtCore.Property was.
Here's relevant docs: https://doc-snapshots.qt.io/qtforpython-dev/PySide6/QtCore/Property.html
Here's a working subclassed combo example that uses a custom property.
from PySide6.QtCore import Property
from PySide6.QtWidgets import QComboBox
class MyCombo(QComboBox):
def __init__(self, parent=None):
super().__init__(parent=parent)
def readXyz(self):
print("read xyz called")
return self.currentIndex()
def setXyz(self, i):
print("set xyz called")
self.setCurrentIndex(i)
xyz = Property(int, readXyz, setXyz)
Or a more pythonic(?) version of property getters and setters that I'm used to:
from PySide6.QtCore import Property
from PySide6.QtWidgets import QComboBox
class MyCombo(QComboBox):
@Property(int)
def xyz(self):
print("read xyz called")
return self.currentIndex()
@xyz.setter
def xyz(self, i):
print("set xyz called")
self.setCurrentIndex(i)