[Interest] Attached properties with Namespaced imports

Shantanu Tushar shaan7in at gmail.com
Sat Jan 28 09:53:46 CET 2017


Ok here's I worked around this by creating another file called
StackViewPage.qml -

```
import QtQuick 2.7
import QtQuick.Controls 2.1

Item {
    property var stackViewStatus: StackView.status
    property int stackViewIndex: StackView.index

    signal stackViewActivated
    signal stackViewActivating
    signal stackViewDeactivated
    signal stackViewDeactivating
    signal stackViewRemoved

    StackView.onActivated: stackViewActivated()
    StackView.onActivating: stackViewActivating()
    StackView.onDeactivated: stackViewDeactivated()
    StackView.onDeactivating: stackViewDeactivating()
    StackView.onRemoved: stackViewRemoved()
}
```

which then works fine like this-

```
import QtQuick 2.7
import QtQuick.Controls 2.1 as C2

C2.ApplicationWindow {
    visible: true
    width: 640
    height: 480

    C2.StackView {
        anchors.fill: parent

        Component.onCompleted: push(rectComponent)
    }

    Component {
        id: rectComponent

        StackViewPage {
            onStackViewStatusChanged: console.log("Status is " +
stackViewStatus)
        }
    }
}
```

Now the question is that is this how attached properties are supposed
to work? Or should I file a bug?

On Sat, Jan 28, 2017 at 12:15 AM, Shantanu Tushar <shaan7in at gmail.com> wrote:
> Hi,
>
> Ah I think I made a typo while preparing the code snippet. I tried
> what you suggested as well, doesn't work.
>
> Also, something I just noticed in GammaRay, "QQuickStackAttached" is
> missing in the properties list for the Rectangle in the code sample
> which doesn't work. Here's a screenshot http://i.imgur.com/OEVZQZA.png
>
>
> On Sat, Jan 28, 2017 at 12:03 AM, J-P Nurmi <jpnurmi at qt.io> wrote:
>> Hi,
>>
>> Try this:
>>
>>     C2.StackView.onStatusChanged: console.log("Status is " + C2.StackView.status)
>>
>> --
>> J-P Nurmi
>>
>>> On 27 Jan 2017, at 18:48, Shantanu Tushar <shaan7in at gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> I realized today that this doesn't work-
>>>
>>> import QtQuick 2.7
>>> import QtQuick.Controls 2.1 as C2
>>>
>>> C2.ApplicationWindow {
>>>    visible: true
>>>    width: 640
>>>    height: 480
>>>
>>>    C2.StackView {
>>>        anchors.fill: parent
>>>
>>>        Component.onCompleted: push(rectComponent)
>>>    }
>>>
>>>    Component {
>>>        id: rectComponent
>>>
>>>        Rectangle {
>>>            color: "green"
>>>            C2.StackView.onStatusChanged: console.log("Status is " +
>>> StackView.status)
>>>        }
>>>    }
>>> }
>>>
>>> "Status is" is never printed. However if I import without the "as C2"
>>> and use "StackView.onStatusChanged", the message is printed.
>>>
>>> The reason I need to do this is that we are still using QtQuick
>>> Controls 1 throughout our project and want to use StackView from
>>> QtQuick.Controls 2 because we need the "StackView.onRemoved"
>>> functionality.
>>>
>>> Any idea how to make the attached property's signal work?
>>>
>>> Cheers,
>>>
>>> --
>>> Shantanu Tushar    (UTC +0530)
>>> shantanu.io
>>> _______________________________________________
>>> Interest mailing list
>>> Interest at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/interest
>
>
>
> --
> Shantanu Tushar    (UTC +0530)
> shantanu.io



-- 
Shantanu Tushar    (UTC +0530)
shantanu.io



More information about the Interest mailing list