[PyQt] Error when double clicking

dizou di_zou at yahoo.com
Thu Nov 19 14:37:01 GMT 2009




Phil Thompson-5 wrote:
> 
> On Tue, 17 Nov 2009 10:32:01 +0100, Mads Ipsen <mpi at comxnet.dk> wrote:
>> 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_())
> 
> You are reimplementing QAbstractItemView.edit(). Call your method
> something
> else.
> 
> Phil
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> 

What is the PyQt equivalent of:
setEditTriggers(QAbstractItemView::NoEditTriggers)

Also, I am trying to pass into the function the item in the QTreeWidget that
I have double clicked on. The item can be a bunch of different classes that
I created all that inherit QTreeWidgetItem. What should I put in the
SIGNAL('itemDoubleClicked(...)) part of the self.connect(...)
-- 
View this message in context: http://old.nabble.com/Error-when-double-clicking-tp26374244p26421356.html
Sent from the PyQt mailing list archive at Nabble.com.



More information about the PyQt mailing list