Data of QTreeView rows



  • I made a QTreeView with a QStandardItemModel to show some data from a MySQL query as a list and it's working fine. Now I need to get the 'double-click' signal from the QTreeView rows, and fill 3 QLineEdit with the data from the row clicked. How do I get the data from the 'double-clicked' row?



  • You connect a slot to signal "doubleClicked() ":http://doc.qt.nokia.com/4.7/qabstractitemview.html#doubleClicked. The model index contains parent, row and column of the model index clicked. In your slot, you can get the current values via

    @
    int row = index.row();
    QModelIndex parent = index.parent();
    QString str0 = model->data(model->index(row, 0, parent), Qt::EditRole);
    QString str1 = model->data(model->index(row, 1, parent), Qt::EditRole);
    QString str2 = model->data(model->index(row, 2, parent), Qt::EditRole);
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.