<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Is there some reason new-style connection from any signal to
QSignalMapper.map do not appear to work?<br>
<br>
Using old-style self.connect works, i.e.:<br>
<code><br>
#self.connect(self.b1, SIGNAL("clicked()"),<br>
# self.mapper, SLOT("map()"))<br>
#self.connect(self.b2, SIGNAL("clicked()"),<br>
# self.mapper, SLOT("map()"))<br>
</code><br>
But using new-style self.<signal>.connect does not:<br>
<br>
<code></code><code> self.b1.clicked.connect(self.mapper.map)<br>
self.b2.clicked.connect(self.mapper.map)<br>
</code><br>
Here's a complete example:<code><br>
=========================================<br>
from PyQt4.QtCore import *<br>
from PyQt4.QtGui import *<br>
<br>
app = QApplication([])<br>
<br>
class Test(QWidget):<br>
def __init__(self, parent=None):<br>
super(Test, self).__init__(parent)<br>
layout = QVBoxLayout()<br>
<br>
self.b1 = QPushButton("B1")<br>
self.b2 = QPushButton("B2")<br>
<br>
layout.addWidget(self.b1)<br>
layout.addWidget(self.b2)<br>
<br>
self.setLayout(layout)<br>
<br>
self.mapper = QSignalMapper(self)<br>
<br>
self.mapper.setMapping(self.b1, "B1")<br>
self.mapper.setMapping(self.b2, "B2")<br>
<br>
self.b1.clicked.connect(self.mapper.map)<br>
self.b2.clicked.connect(self.mapper.map)<br>
<br>
#self.connect(self.b1, SIGNAL("clicked()"),<br>
# self.mapper, SLOT("map()"))<br>
#self.connect(self.b2, SIGNAL("clicked()"),<br>
# self.mapper, SLOT("map()"))<br>
<br>
self.mapper.mapped[QString].connect(self.sayIt)<br>
<br>
@pyqtSlot(QString)<br>
def sayIt(self, name):<br>
print name<br>
<br>
<br>
t = Test()<br>
<br>
t.show()<br>
<br>
app.exec_()<br>
</code><code>=========================================</code><br>
<br>
cheers, <br>
-Mark<br>
<pre class="moz-signature" cols="72">--
Mark Visser, Software Director
Lumière VFX
Email: <a class="moz-txt-link-abbreviated" href="mailto:markv@lumierevfx.com">markv@lumierevfx.com</a>
Phone: +1-514-316-1080 x3030
</pre>
</body>
</html>