[PyQt] Custom Widgets and __pyqtSignals__

David Boddie david at boddie.org.uk
Mon Aug 25 23:26:41 BST 2008

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.

Note to Phil: the PyDemo example contains a __pyqtSignals__ attribute that
isn't actually a tuple.


More information about the PyQt mailing list