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. ListView delegate isnt able to access model properties after inserting into QAbstractItemModel

ListView delegate isnt able to access model properties after inserting into QAbstractItemModel

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 252 Views 2 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.
  • C Offline
    C Offline
    Creaperdown
    wrote on last edited by
    #1

    I have a QAbstractItemModel that I am exposing to Qml to display. When inserting a new item into it, I properly call the beginInsertRows(QModelIndex(), index, index); and endInsertRows(); functions. The item gets inserted correctly, but my delegate (in a ListView):

    delegate: Rectangle {
                            width: bookmarksView.width
                            height: 24
                            color: "red"
                            opacity: 0.5
    
                            Label {
                                id: bookmarkName
                                anchors.centerIn: parent
                                text: model.name
                                color: Style.colorText
                                font.pointSize: 11
                            }
                        }
    

    gives me an error that it cant assign unkown to QString on the line text: model.name, but after reloading the page it works fine. So it just isnt able to access it right after I have inserted the new item.

    Does someone have an idea why this happens?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      Hi,

      Please don't post the same question in multiple sub-forum. One is enough.

      Duplicate

      Closing this one

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • SGaistS SGaist referenced this topic on
      • SGaistS SGaist locked this topic on

      • Login

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