import sys # If using PyQt4, a QTreeWidget window with a single item will be created and # the following will be printed on the console: # item in dummyList? True # dummyList.index(item) = 2 #from PyQt4 import QtGui # If using PySide, no window will be shown, and the following trace will # be printed on the console: # Traceback (most recent call last): # File "..... NotImplementedError_when_testing_for_membership_in_QTreeWidgetItem.py", line 29, in # print('item in dummyList?', item in dummyList) # NotImplementedError: operator not implemented. from PySide import QtGui app = QtGui.QApplication(sys.argv) treeWidget = QtGui.QTreeWidget() item = QtGui.QTreeWidgetItem(['text of column 0']) treeWidget.insertTopLevelItem(0, item) dummyList = ['foo', 'bar', item] # "item in dummyList" raises a NotImplementedError: operator not implemented. print('item in dummyList?', item in dummyList) # "dummyList.index(item)" raises a NotImplementedError: operator not implemented too. print('dummyList.index(item) = ', dummyList.index(item)) treeWidget.show() app.exec_() sys.exit()