TableView get value from of desired role inside 'onDoubleClicked'
Solved
QML and Qt Quick
-
Hi there, I want to get the value for the role 'id' inside the method 'onDoubleClicked', but the only thing I can get is the row number. I could not use model.data() because there is no class QModelIndex.
Can someone help me with this?TableView { id: tview Layout.fillWidth: true Layout.fillHeight: true model: dashboardProvider.getModel() onDoubleClicked: { console.log(row); //dashboardProvider.openWidget(id) } . . . }
-
-
I implemented MyModel class that extends QAbstractTableModel and the get(int row) method
but I'm getting the following:
TypeError: Property 'get' of object QAbstractTableModel(0x1ae8030)onDoubleClicked: { console.log(model.get(row).id) }
-
I found a solution:
onDoubleClicked: { console.log(model.data(model.index(row,0), 256)) // 256 => Qt::UserRole }