[PyQt] Error when double clicking
Mads Ipsen
mpi at comxnet.dk
Tue Nov 17 09:32:01 GMT 2009
dizou wrote:
> I have a class that inherits QTreeWidget, in the __init__ I am trying to
> connect a double click with a function:
>
>
> class TreeArea(QTreeWidget):
> def __init__(self, parent):
> .
> .
> .
> self.connect(self, SIGNAL("itemDoubleClicked(QTreeWidgetItem *)"),
> self.edit)
>
> def edit(self, item):
> .
> .
> .
>
> However, when I run the program and click on an item I get this error:
> TypeError: edit() takes exactly 2 arguments (4 given)
>
> Also, what is the PyQt equivalent of:
> setEditTriggers(QAbstractItemView::NoEditTriggers)
>
I also get the same error with the example included below. Any clues?
import sys
from PyQt4 import QtCore, QtGui
class TreeWidget(QtGui.QTreeWidget):
def __init__(self, parent=None):
QtGui.QTreeWidget.__init__(self, parent)
# Add an item
item = QtGui.QTreeWidgetItem(['1'], 0)
self.addTopLevelItem(item)
# Connect
self.connect(self, QtCore.SIGNAL('itemDoubleClicked (
QTreeWidgetItem *, int)'), self.edit)
def edit(self, item, column):
print 'Clicked'
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
widget = TreeWidget()
widget.show()
sys.exit(app.exec_())
--
+-------------------------------------------------------------+
| Mads Ipsen, Scientific developer |
+-------------------------------+-----------------------------+
| QuantumWise A/S | phone: +45-29716388 |
| Nørre Søgade 27A | www: www.quantumwise.com |
| DK-1370 Copenhagen K, Denmark | email: mpi at quantumwise.com |
+-------------------------------+-----------------------------+
More information about the PyQt
mailing list