qt - Adding custom properties to QML type -


i new qml , seasoned c++. have been trying go through qml examples try , learn it.

i playing around tumblercolumn control (from examples) , trying set model set year. goes like:

tumblercolumn {     id: yearcolumn     width: charactermetrics.width * 4 + tumbler.delegatetextmargins      model: listmodel {         component.oncompleted: {             (var = 2000; < 2100; ++i) {                 append({value: i.tostring()});             }         }     }     oncurrentindexchanged: tumblerdaycolumn.updatemodel() } 

now, made change like:

tumblercolumn {     id: yearcolumn     width: charactermetrics.width * 4 + tumbler.delegatetextmargins      property int startyear: 2000     property int endyear: 3000      model: listmodel {         component.oncompleted: {             (var = startyear; < endyear; ++i) {                 append({value: i.tostring()});             }         }     }     oncurrentindexchanged: tumblerdaycolumn.updatemodel() } 

this returns error:

referenceerror: startyear not defined

how can define these readonly constant properties such qml element.

startyear , endyear aren't in scope. try this

tumblercolumn {     id: yearcolumn     width: charactermetrics.width * 4 + tumbler.delegatetextmargins      property int startyear: 2000     property int endyear: 3000      model: listmodel {         component.oncompleted: {             (var = yearcolumn.startyear; < yearcolumn.endyear; ++i) {                 append({value: i.tostring()});             }         }     }     oncurrentindexchanged: tumblerdaycolumn.updatemodel() } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -