Is there some reason new-style connection from any signal to QSignalMapper.map do not appear to work?

Using old-style self.connect works, i.e.:
|
       #self.connect(self.b1, SIGNAL("clicked()"),
       #             self.mapper, SLOT("map()"))
       #self.connect(self.b2, SIGNAL("clicked()"),
       #             self.mapper, SLOT("map()"))
|
But using new-style self.<signal>.connect does not:

|||        self.b1.clicked.connect(self.mapper.map)
       self.b2.clicked.connect(self.mapper.map)
|
Here's a complete example:|
=========================================
from PyQt4.QtCore import *
from PyQt4.QtGui import *

app = QApplication([])

class Test(QWidget):
   def __init__(self, parent=None):
       super(Test, self).__init__(parent)
       layout = QVBoxLayout()
self.b1 = QPushButton("B1")
       self.b2 = QPushButton("B2")

       layout.addWidget(self.b1)
       layout.addWidget(self.b2)

       self.setLayout(layout)

       self.mapper = QSignalMapper(self)

       self.mapper.setMapping(self.b1, "B1")
       self.mapper.setMapping(self.b2, "B2")

       self.b1.clicked.connect(self.mapper.map)
       self.b2.clicked.connect(self.mapper.map)

       #self.connect(self.b1, SIGNAL("clicked()"),
       #             self.mapper, SLOT("map()"))
       #self.connect(self.b2, SIGNAL("clicked()"),
       #             self.mapper, SLOT("map()"))

       self.mapper.mapped[QString].connect(self.sayIt)

   @pyqtSlot(QString)
   def sayIt(self, name):
       print name
t = Test()

t.show()

app.exec_()
||=========================================|

cheers,
-Mark

--
Mark Visser, Software Director
Lumière VFX
Email: [email protected]
Phone: +1-514-316-1080 x3030

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to