Invoking context menu in QTreeWidget
问题 I would like to popup a menu, when user clicks on an object in QTreeWidgetItem. I though about catching signal contextMenuRequested from QWidget and then retrieving index from the view using itemAt. But this doesn't seem very pretty. Is there any easier way to be able to call a menu on an item inside a view? 回答1: Write your own custom ItemDelegate and handle the click event in QAbstractItemDelegate::editorEvent . You can retreive the data in the cell from the QModelIndex. In C++ it would look