Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

How to disable a property:

$
0
0
Hi I am defining my own Qml Item in one file (Tile.qml) as like below. Rectangle { id : tile width: 100 height: 100 color : “red” property alias text : txt.text property alias bgColor : tile.color property alias fontColor : txt.color property alias fontSize : txt.font.pixelSize MouseArea { anchors.fill: parent onClicked: { console.log(txt.text); } } Text { id : txt anchors.centerIn: parent } } and using this user defined item multiple times in another file like this Column { spacing : 5 Row { spacing: 5 Tile { id : obj11; text: “obj11”; bgColor : “red”; fontColor : “Yellow”} Tile { id : obj12; text : “obj12”; bgColor : “red”; fontColor : “Black”} Tile { id : obj13; text : “obj13”; bgColor : “red”; fontColor : “Black”} } Row { spacing: 5 Tile { id : obj21; text: “obj21”; bgColor : “red”; fontColor : “Yellow”} Tile { id : obj22; text : “obj22”; bgColor : “red”; fontColor : “Black”} Tile { id : obj23; text : “obj23”; bgColor : “red”; fontColor : “Black”; width : 200} } } Here I am actually using the tile item multiple places and able to make changes on any property. But, I want to restrict the Tile width to 100 and height to 100 all the time. For that I want to disable these two properties so that they would not be accessible from outside. At the same time, I want to give control over all other properties. If I use nested Rectangle to define tile… in that case I supposed to do property alias for all other properties, that would be a over headache to me. How can I achieve this, any help is highly appreciable.

Viewing all articles
Browse latest Browse all 4972

Trending Articles