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

qt-qml-id ReferenceError after setContextPropertiy



  • MouseArea{
    	anchors.fill: parent
    	onClicked: {
    		fileList.currentIndex = index
    		mainView.openFile(modelData); // call C++ context->setContextPropertiy("", ""), 
    		console.log(fileList) // error: ReferenceError: fileList is not defined
    	}
    }
    

    how can i use id(fileList) after setContextPropertiy?



  • let obj = tabView // save param before call setContextPropertiy
    let tabName = name // save model item attr
    fileList.currentIndex = index
    mainView.openFile(modelData); // call C++ context->setContextPropertiy("", ""), 
    console.log(obj) // res: qml: TabView_QMLTYPE_10(0x3c5a220)
    obj.addTab(tabName)
    

    i do this, it work, but I dont not know why?



  • @make2 i refresh model of a ListView by setContextProperty



  • let obj = tabView // save param before call setContextPropertiy
    let tabName = name // save model item attr
    fileList.currentIndex = index
    mainView.openFile(modelData); // call C++ context->setContextPropertiy("", ""), 
    console.log(obj) // res: qml: TabView_QMLTYPE_10(0x3c5a220)
    obj.addTab(tabName)
    

    i do this, it work, but I dont not know why?


Log in to reply