How to get the selected item in a QTreeView?

479 views Asked by At
void CatchSelection(QModelIndex item)
{
    if(item.row() == -1)
    {
        return;
    }

    if (item.parent().row() != -1)
    {
        QModelIndex idx = model()->index(item.row(), 1, item.parent());

        __int64 value = model()->data(idx).toLongLong();
    }
}

The above code doesn't work. I'm trying to get data out of a Qt 5.1 QTreeView when the user clicks on an item. Then I'm trying to select the 2nd column of that item (it has a number I need).

What am I missing?

0

There are 0 answers