[PyQt] Custom Widgets and __pyqtSignals__
Marco Fabiani
himork at kth.se
Tue Aug 26 07:38:17 BST 2008
David Boddie wrote:
> On Mon, 25 Aug 2008 11:58:14 +0200, Marco Fabiani wrote:
>
>> A follow up to my previous email: the code I posted didn't crash because
>> it was not doing what it was meant to do. What I am trying to do is to
>> subclass QSlider in order to emit a custom signal
>> valueDoubleChanged(double) that is just value/100. Here is my code that
>> crashes designer, I wonder if you could give me a hand with this:
>
> [...]
>
>> class myDoubleSlider(QSlider):
>>
>> __pyqtSignals__ = ("valueDoubleChanged(double)",)
>>
>> def __init__(self,parent = None):
>>
>> QSlider.__init__(self,parent)
>> self.setOrientation(Qt.Horizontal)
>> self.connect( self , SIGNAL("valueChanged(int)") ,
>> self.setValueDouble)
>>
>> @pyqtSignature("setValueDouble(double)")
>> def setValueDouble(self):
>> self.emit(SIGNAL("valueDoubleChanged(double)") ,
>> self.value()/100)
>
> I suppose this might be a problem if the value isn't actually a Python
> float object, but I failed to get Qt Designer to crash with a custom
> widget doing something similar. If I get a chance, I'll wrap up your code
> in a Designer plugin and see what happens.
Hi David,
thank you for looking that up. I actually managed to make my widget work
in Designer. There were a few problems (one was that I had to convert
int to float before dividing it by 100, otherwise the result was always
0.00), and it is kinda difficult to track down which is the cause of the
crash when importing the widget in Designer.
Thank you very much again
Marco
>
> Note to Phil: the PyDemo example contains a __pyqtSignals__ attribute that
> isn't actually a tuple.
>
> David
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
More information about the PyQt
mailing list