Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTreeWidget Signal itemDoubleClicked Returns QModelIndex?



  • I have a QTreeWidget with QTreeWidgetItems or in my case CustomTreeItems and when I use the signal itemDoubleClicked instead of returning a QTreeWidgetItem it returns a QModelIndex. Is this normal behavior?

    CODE:

    def on_double_click_tree(self, currItem):
            print(currItem)
            print("row: ",currItem.row())
            print("data: ",currItem.data())
            print("parent: ",currItem.parent())
    
    self.modemTree.doubleClicked.connect(self.on_double_click_tree)
    
    def on_select_tree_item(self, currItem):
              print(currItem)
    
    self.modemTree.itemClicked.connect(self.on_select_tree_item)
    

    A single click returns a CustomTreeItem (QTreeWidgetItem) which is expected, however a double click returns the QModelIndex which is not expected.

    OUTPUT:
    0_1500567823114_92782410-0577-4d3f-a78b-0eceec99bdfb-image.png



  • Yes, but you can access the Data by using the method data() from the QModelIndex


Log in to reply