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:[email protected]] On Behalf Of 
Elvis Stansvik
Sent: 21 March 2016 12:38
To: [email protected] Interest <[email protected]>
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
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to