Marco Fabiani wrote:
David Boddie wrote:
On Sun Aug 24 12:43:33 BST 2008, Paul Giannaros wrote:
On Sun, Aug 24, 2008 at 12:03 PM, himork <himork at kth.se> wrote:
I am trying to write a custom widget in python/pyqt to be used inside
QtDesigner. Everything seems to work fine (i followed the tutorials and
examples available), except for the signals: when I use __pyqtSignals__ =
("mysignal(double)"), the widget ends up having one signal for each
letter of "mysignal(double)", parenthesis included, like it cannot
understand that this is a string.
Paul's explanation is correct. This is an interesting side effect of the
fact that PyQt accepts any kind of sequence for __pyqtSignals__.

The comma worked, thank you!

And if I had 2 signals, designer crashes when I try to add my custom
widget.
Can you say what you wrote for __pyqtSignals__ in that case? I would be
interested to know why it caused a crash.

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:

----------
from PyQt4.QtCore import *
from PyQt4.QtGui import *

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)
                
                
if __name__ == "__main__":

    import sys

    app = QApplication(sys.argv)
    slider = myDoubleSlider()
    slider.show()
    sys.exit(app.exec_())       

-----

Thank you
Marco


The crash happens when I pass __pyqtSignal__ a tuple (so it happened
with the single signal + comma as well). Here is part of the code:

[...]

__pyqtSignal = ("valueDChanged(double)",)

[...]
        @QtCore.pyqtSignature("setValueDouble(double)")
        def setValueDouble(self, value = None):
                if value !=self.valueD:
                        if value is not None:
                                self.valueD = value
                        self.setValue(int(round(self.valueD*100)))
                seelf.emit(QtCore.SIGNAL("valueDChanged(double)"),value)
                        self.update()
[...]


I managed not to crash designer by using self.valueD instead of value
when I emit the signal. My guess is that the problem is "value" that by
default is "None", am I right?

Thanks for the help!
Marco
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

--
|++++++++++++++++++++++++++++++++++++
| Fabiani Marco
| Speech, Music and Hearing, KTH
| Lindstedtsv. 24
| S-100 44 Stockholm (Sweden)
| Mobile:       +46-(0)73-817 4751
| Office:       +46-(0)8-790 7597
| Fax:          +46-(0)8-790 7854
| Italy (Voip): +39-0462-936 330
|++++++++++++++++++++++++++++++++++++
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to