[Interest] Exposing nested visual properties in FocusScope (alias -> alias problem)
Mark Tucker
mark.tucker at airborne.aero
Mon Mar 21 15:14:14 CET 2016
Hello,
As long as your internal Text item has an id, then you can add the aliases in the FocusScope. This should work:
FocusScope {
property alias text: text.text
property alias textPixelSize: text.font.pixelSize
Rectangle {
id: button
focus: true
width: text.implicitWidth
height: text.implicitHeight
Text {
id: text
...
}
}
}
-----Original Message-----
From: Interest [mailto:interest-bounces+mark.tucker=airborne.aero at qt-project.org] On Behalf Of Elvis Stansvik
Sent: 21 March 2016 12:38
To: interest at qt-project.org Interest <interest at qt-project.org>
Subject: [Interest] Exposing nested visual properties in FocusScope (alias -> alias problem)
Hi all,
I'm trying to create a reusable component for a button. Right now I'm trying to figure out focus handling (the app is keyboard navigation only).
I currently have the following structure (Button.qml):
Rectangle {
id: button
property alias text: text.text
property alias textPixelSize: text.font.pixelSize
width: text.implicitWidth
height: text.implicitHeight
Text {
id: text
...
}
}
Where I'm exposing the text and pixelSize properties of the text by using property aliases, to be able to use it like:
Button {
text: "Foo bar"
textPixelSize: 42
}
This works fine. But now I'd like the component to be able to participate in focus handling, so I wrap it in a FocusScope, e.g:
FocusScope {
Rectangle {
id: button
focus: true
property alias text: text.text
property alias textPixelSize: text.font.pixelSize
width: text.implicitWidth
height: text.implicitHeight
Text {
id: text
...
}
}
}
Which should allow me to use it in other nested focus scopes at a higher level in the visual tree
The problem now is that I must expose the button.text and button.textPixelSize in the FocusScope, to be able to use the component as before. But I can't use property aliases again, since a property alias may not refer to another property alias.
Anyone know how I can get around this?
Thanks in advance,
Elvis
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list