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] Function in listview
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Function in listview

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 2.0k 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.
  • F Offline
    F Offline
    fmontigny
    wrote on last edited by
    #1

    Hi,

    I have my list view
    @ ListView {
    id: groupList
    anchors.fill: parent

                model: ContactModel6 {}
                delegate: RowGroup {}
            }@
    

    and my item
    @Rectangle {
    id: rowGroup

    Rectangle {
        id: rectRowGroup
    
        TextEdit {
            id: bigtitle
            text: title
        } 
    

    function switchtitle(t)
    {
    bigtitle.text = t;
    }
    }@

    I want to access to my function switchtitle to item number 2
    How i can do this?

    I try @groupList.pos(3).switchtitle("new title")@ but that don't work

    Thx

    EDIT: moved to QtQuick, Gerolf

    fmontigny

    "time is for all cannot simultaneously"

    [FRANCE]

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Amnell
      wrote on last edited by
      #2

      Hi,

      You can't access to a ListView Item through this utopic pos() because ListView's items are instancied and deleted dynamicaly when you scroll the area, for performances purpose (that's why there is only a "currentItem" property and not anything else).

      I suggest you to remove your unneeeded switchtitle() function and to replace :

      @groupList.pos(3).switchtitle("new title")@

      By :

      @groupList.model.get(3).title = "new title";@

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fmontigny
        wrote on last edited by
        #3

        Thx.

        I can't access a function?

        fmontigny

        "time is for all cannot simultaneously"

        [FRANCE]

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          You can't access a delate, and that includes functions of that delegate.

          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