[PyQt] Custom Widgets and __pyqtSignals__

Marco Fabiani himork at kth.se
Mon Aug 25 08:46:27 BST 2008


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.

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


More information about the PyQt mailing list