[Eric] How do you detect such an error?
David Arnold
dwarnold45 at suddenlink.net
Sun Feb 14 05:48:02 GMT 2010
All,
What do you do when your code doesn't seem to throw any errors but does not work as expected? In this case, the error lies in:
self.connect(slider, QtCore.SIGNAL('valuechanged(int)'), lcd,
QtCore.SLOT('display(int)'))
Which should be:
self.connect(slider, QtCore.SIGNAL('valueChanged(int)'), lcd,
QtCore.SLOT('display(int)'))
How can you find errors like this?
David
# sigslot.py
import sys
from PyQt4 import QtGui, QtCore
class SigSlot(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setWindowTitle('Signals and Slots')
lcd = QtGui.QLCDNumber(self)
slider=QtGui.QSlider(QtCore.Qt.Horizontal, self)
vbox=QtGui.QVBoxLayout()
vbox.addWidget(lcd)
vbox.addWidget(slider)
self.setLayout(vbox)
self.connect(slider, QtCore.SIGNAL('valuechanged(int)'), lcd,
QtCore.SLOT('display(int)'))
self.resize(250, 150)
app=QtGui.QApplication(sys.argv)
ss=SigSlot()
ss.show()
sys.exit(app.exec_())
More information about the Eric
mailing list