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. Cannot read property of null warnings when scrolling TreeView

Cannot read property of null warnings when scrolling TreeView

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

    Hi
    I have a TreeView which uses a QSortFilterProxyModel from C++. Inside the delegate, I use the model.[role] syntax instead of styleData.value to get the model data because I display several different model roles inside the itemDelegate for the only column in the view.

    Although the data is displayed correctly, I get warnings like the following:

    TypeError: Cannot read property 'title' of null
    

    These warnings only appear when I scroll the view, probably when new delegates are being instantiated.

    The question therefore is why these warnings are generated, since the model is set, exists and is never modified.

    To avoid the warnings, I use something like:

    Text {
       text: model ? model.title  : ""
    }
    

    But clearly, the above is really only a workaround.

    Note that when I use styleData.value (assuming the role for that column is set to "title"), I don't get the warning for that particular role.

    Surely, this must be a bug of sorts? I can't imagine I must keep doing this model ? model.A : B check every time I access a model role inside the delegate...

    Thanks for any comments you may have on this.
    Cheers!

    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