c++ - Treeview model properties are null in delegate warning -


i have treeview

treeview {         id: dndview         rowdelegate: item {             height: 30         }         itemdelegate:  dnddelegate         model: mymodel         tableviewcolumn {             title: "name"             resizable: true         } } 

and delegate does work

rectangle {     id: dragrect     anchors.horizontalcenter: parent.horizontalcenter     anchors.verticalcenter: parent.verticalcenter     color: 'gray'     width: dndview.width - 20     height: 30     image {         id: menuitemimage         anchors.verticalcenter:parent.verticalcenter         source:model.commandicon     }     text {         anchors.left:menuitemimage.right         anchors.verticalcenter:parent.verticalcenter         text:model.commandtitle         font.pixelsize: 14     } 

roles in c++ file:

qhash<int, qbytearray> menutreemodel::rolenames() const {     qhash<int, qbytearray> roles;     roles[titlerole] = "commandtitle";     roles[iconrole] = "commandicon";     return roles; } 

it displays text , icon correctly nevertheless when expand items or close application have warnings:

qrc:/draggablerectangle.qml:15: typeerror: cannot read property 'commandicon' of null qrc:/draggablerectangle.qml:20: typeerror: cannot read property 'commandtitle' of null*

what's wrong it?

if warnings appear on specific events, may mean model destroyed or not yet created when qml view tries use it.

e.g. if model destroyed before view when close application, view still tries use destroyed object short time (before it's destroyed too).

try :

text: model ? model.commandtitle : "" 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -