Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

qml listview ListView.view accessed from highlight is null



  • ListView
    {
            width: 274
            height: count > 0 ? 0 : contentHeight
            spacing: 2
            highlightFollowsCurrentItem: true
    
            model: assignTargetModel
            //delegate: lvDelegate
            highlight: lvHighlight
        
            Component
            {
                 id: lvHighlight
                 Item
                 {
                      id: item
                       width: 274
                      height: 56
                       Image
                       {
                           source: (item.index === /*item.*/ListView.view.count - 1) ? "qrc:/Analysis/assets/target5_bg2_3615_778.png" : "qrc:/Analysis/assets/a_b_bg1_3615_757.png"
                       }
                  }
    }
    

    Right in delegate, I guess highlight is created dynamically and the highlight is undefined by default. And so the ListView.view has not been attached to delegate.
    If so, this is a terrible way that can cause unintentional errors.


Log in to reply