<div>You need to call QToolButton's __init__() method.<br></div><div><br></div><div>
class Indicator(QtGui.QToolButton, Model):
</div><div> def __init__(self)</div><div> super(Indicator, self).__init__()</div><br><div class="gmail_quote">On Fri, Jul 8, 2011 at 1:49 PM, Lic. José M. Rodriguez Bacallao <span dir="ltr"><<a href="mailto:jmrbcu@gmail.com">jmrbcu@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">hi folks, I am creating a composite widget with PyQt4 and Dip, the<br>
problem I have is that when I use dip properties for setting PyQt4<br>
properties in the constructor I am getting an error saying that the<br>
underlying C++ object has been delete, I think this is due to the way<br>
dip works because it call properties methods before the actual Qt4<br>
widget as been created when I pass an initial value in the<br>
constructor. When I construct the object with properties initial<br>
values and the use the properties accesors to set the value, this<br>
doens't happen. So, my question is, which is the right way to<br>
construct a custom composite widget with dip?<br>
<br>
# dip imports<br>
from dip.model import Model, Instance, Str<br>
<br>
# PyQt4 imports<br>
from PyQt4 import QtCore, QtGui<br>
<br>
class Indicator(QtGui.QToolButton, Model):<br>
<br>
# the indicator identifier, it must be unique for all indicators<br>
id = Str()<br>
<br>
# the indicator text, this text will be shown<br>
# beside the icon if one is defined<br>
text = Str()<br>
<br>
# the indicator tooltip<br>
tooltip = Str()<br>
<br>
# the indicator icon<br>
icon = Instance(QtGui.QIcon)<br>
<br>
@id.getter<br>
def id(self):<br>
print 'getting value'<br>
return self.objectName()<br>
<br>
@id.setter<br>
def id(self, id):<br>
print 'setting value'<br>
self.setObjectName(id)<br>
<br>
@text.getter<br>
def text(self):<br>
return self.text()<br>
<br>
@text.setter<br>
def text(self, text):<br>
self.setText(text)<br>
<br>
@tooltip.getter<br>
def tooltip(self):<br>
return self.toolTip()<br>
<br>
@tooltip.setter<br>
def tooltip(self, tooltip):<br>
self.setToolTip(tooltip)<br>
<br>
@icon.getter<br>
def icon(self):<br>
return self.icon()<br>
<br>
@icon.setter<br>
def icon(self, icon):<br>
self.icon = icon<br>
<br>
def perform(self):<br>
raise NotImplementedError<br>
<br>
if __name__ == '__main__':<br>
app = QtGui.QApplication([])<br>
<br>
i = Indicator(text='xxx')<br>
i.show()<br>
<br>
app.exec_()<br>
<br>
--<br>
Lic. José M. Rodriguez Bacallao<br>
Centro de Biofisica Medica<br>
-----------------------------------------------------------------<br>
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.<br>
<br>
Recuerda: El arca de Noe fue construida por aficionados, el titanic<br>
por profesionales<br>
-----------------------------------------------------------------<br>
_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></blockquote></div><br>