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

How to call a method of a QModelIndex object from QML?



  • In the following example index is an object of the QModelIndex class:

    var s = index.sibling(0, 0)
    

    The execution leads to the following error:

    TypeError: Property 'sibling' of object QModelIndex(0,0,0x286a3e0,FileSystemModel(0x19bc150)) is not a function
    

    The same error type occurs with the following line:

    var s = index.row()
    

    But using row as a property like in the following line works:

    var s = index.row
    

    So, what's going wrong here? How can I call a method of a QModelIndex object in a QML file?


Log in to reply