from PyQt5.Qt import * if __name__ == '__main__': app = QApplication([]) x = QTreeWidget() x.setContextMenuPolicy(Qt.CustomContextMenu) i1 = QTreeWidgetItem(x, ["A"]) i2 = QTreeWidgetItem(i1, ["bar", "i", "ii"]) i3 = QTreeWidgetItem(i2, ["baz", "a", "b"]) def callback(point): menu = QMenu() menu.addAction("Foo") menu.addSeparator() menu.addAction("Bar") menu.exec_(x.mapToGlobal(point)) x.customContextMenuRequested.connect(callback) x.show() app.exec_()