[solved][TableView] Access of elements and data
I would like to know how can I know in which element I am when a modification is done on one of the delegate item of a row.
I have a C++ back end sending a QList<Object*> to a TableView that using it as its model. One of the role is a boolean displayed as a switch button "On/Off" I would like to know if it's possible to access to the current element that embed the switch button to, for example, update a list, access another item of the element, etc... I know there is currentRow function but the click of the switch catches the event I think because it's not updated.
Second question : I have a role in my model that is not loaded in the TableView. It's an ip address that I want to display as a tooltip when the item containing the id of the element is hovered. I tried to access to the ip adress like this (from the id delegate) :
but the interpreter is saying this then : @TypeError: Property 'get' of object [object Object] is not a function@
I think it's maybe because the model is a QList passed from C++ but how can I fix it then ?
Thank in advance for any help for this, this is really critical for my project :)
I've subclass QAbstractListModel to manage my model instead of the QList and after many search, it seems to work to get data from it. But still, I don't understand how to easily access to the current index/row of the TableView when I do a modification on a delegate.
For example, if I clicked on a switch button, it doesn't trigger the row change. So I don't know how to access to the row of the element I'm modifying and so I can't update the data linked to the switch button with setData(). Something I missed ? Any idea how to do so ?
Ok my bad, I didn't see that styleData.row :) Should be right now ;)