Error of 'TypeError: Cannot read property 'name' of undefined' when it comes start to end or vice-versa of application window by moving mouse wheel scroll



  • Hello everyone,

    I am working on qml, found found an error during moving mouse wheel scrolling i.e. "TypeError: Cannot read property 'name' of undefined".

    It only appear when either mouse wheel scrolling or close the application while during execution and beginning of the application didn't show this error.

    One more thing, I am getting accurate data/result whatever I want but due to this error the performance of application get affected.

    Please let me know how can I get rid of this issue?

    also find below example to see error.

    import QtQuick 2.4
    import QtQuick.Controls 1.3
    import QtQuick.Layouts 1.1
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        menuBar: MenuBar {
            Menu {
                title: qsTr("File")
                MenuItem {
                    text: qsTr("Exit")
                    onTriggered: Qt.quit();
                }
            }
        }
    
        TableView {
            anchors.fill: parent
            visible: true
            backgroundVisible: false
            alternatingRowColors: false
            sortIndicatorVisible: true
            clip: true
            highlightOnFocus: false
            width: parent.width
            height: parent.height
    
    
            TableViewColumn{ role: "code"  ; title: "cde" ; width: 200;
                delegate: Component {
                    id: codeDelegate
                    Item{
                    Text {
                        color: "lightgray"
                        elide: styleData.elideMode
                        text: styleData.value //modelSettingData.get(styleData.row).name
                        font.family: "Arial"
                        font.pixelSize: 18
                        wrapMode: Text.WrapAtWordBoundaryOrAnywhere
    
                        Text {
                            id: metaData
                            color: "red"
                            width: parent.width
                           // height: 20
                            anchors.bottom: parent.bottom
                            anchors.bottomMargin: -parent.height/1.5
                            font.weight: Font.ExtraLight
                            //elide: Text.ElideMiddle
                            text: "Time: " + modelSettingData.get(styleData.row).name  //Error comes when this part added but I need to use it with the same form
                        }
                    }
                    }
                }
    
            }
            TableViewColumn{ role: "name" ; title: "nme" ; width: 200
                delegate: Component {
                    id: nameDelegate
                    Text {
                        color: "yellow"
                        elide: styleData.elideMode
                        text: styleData.value
                        font.family: "Arial"
                        font.pixelSize: 18
                    }
                }
    
            }
    
            model: ListModel {
                id: modelSettingData
                ListElement {
                    name: "aaaaaaaaaa"
                    code: "3042666666666"
                }
                ListElement {
                    name: "bbbbbb"
                    code: "32235"
                }
                ListElement {
                    name: "ccccccc"
                    code: "32638"
                }
    
                ListElement {
                    name: "ddddddddddd"
                    code: "00000000000"
                }
                ListElement {
                    name: "eeeeeeeeeeee"
                    code: "111111111111"
                }
                ListElement {
                    name: "ffffffffffff"
                    code: "222222222222"
                }
    
                ListElement {
                    name: "ggggggggggggg"
                    code: "3333333333333"
                }
                ListElement {
                    name: "hhhhhhhhhhhhh"
                    code: "4444444444444"
                }
                ListElement {
                    name: "iiiiiiiiiiiii"
                    code: "5555555555555"
                }
            }
            rowDelegate: Rectangle {
                property bool selected : styleData.selected
                width: parent.width-2
                height: 100
                color: styleData.selected? "black" : "black"
                Rectangle {
                    width: parent.width
                    height: 1
                    anchors.bottom: parent.bottom
                    visible: parent.selected
                    color: "yellow"
                }
            }
    
        }
    
    }
    


  • Yeah I did resolve at my end..:)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.