I'm creating a widget for QtDesigner, using python and pyqt4. In order to create a Qt property I wrote the following code:<br><br>[...]<br>def set_axis(self, axis):<br> print "DEBUG: set_axis"<br> self._axis = axis<br>
def get_axis(self):<br> print "DEBUG: get_axis"<br> return self._axis<br>axisName = pyqtProperty("QString", get_axis, set_axis)<br>[...]<br><br>In the Designer, I can create the widget with no problem at all and I can change the property value as well. I get both "DEBUG" prints. I save the form as mydialg.ui.<br>
<br>The problem is on the main program, when I try to load the form. I use uic.LoadUi("mydialog.ui") and get the following error:<br><br>Traceback (most recent call last):<br> File "main.py", line 8, in <module><br>
window = uic.loadUi("mydialog.ui")<br> File "/usr/lib/python2.5/site-packages/PyQt4/uic/__init__.py", line 106, in loadUi<br> return loader.DynamicUILoader().loadUi(uifile, baseinstance)<br> File "/usr/lib/python2.5/site-packages/PyQt4/uic/Loader/loader.py", line 22, in loadUi<br>
return self.parse(filename)<br> File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line 572, in parse<br> actor(elem)<br> File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line 431, in createUserInterface<br>
self.traverseWidgetTree(elem)<br> File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line 409, in traverseWidgetTree<br> handler(self, child)<br> File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line 155, in createWidget<br>
self.stack.push(self.setupObject(widgetClass(elem), parent, elem))<br> File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line 131, in setupObject<br> self.wprops.setProperties(obj, branch)<br>
File "/usr/lib/python2.5/site-packages/PyQt4/uic/properties.py", line 293, in setProperties<br> propname[1:]))(self.convert(prop, widget))<br>AttributeError: setAxisName<br><br>It seems that the loading form code is expecting the "set" method named in a different way.<br>
So I replaced my code with this one:<br>[...]<br>
def setAxisName(self, axis):<br>
print "DEBUG: set_axis"<br>
self._axis = axis<br>
def get_axis(self):<br>
print "DEBUG: get_axis"<br>
return self._axis<br>
axisName = pyqtProperty("QString", get_axis, setAxisName)<br>
[...]<br>
<br>And now it works perfectly (both on Designer and my program).<br>Is this a bug?<br><br><br clear="all">Emiliano<br><br>-- <br>life's better without braces - Bruce Eckel<br>