Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved][TableView] Access of elements and data
Forum Updated to NodeBB v4.3 + New Features

[solved][TableView] Access of elements and data

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 1 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zanis
    wrote on last edited by
    #1

    Hello,

    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.

    Explanation :

    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) :

    @playerView.model.get(styleData.value).attributes.get(8).value@

    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 :)

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      Zanis
      wrote on last edited by
      #2

      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 ?

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        Zanis
        wrote on last edited by
        #3

        Ok my bad, I didn't see that styleData.row :) Should be right now ;)

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved