Re: [Interest] How to determine whether QML item is anchored?
You might want to check the state since you use the state to change the anchors. You could add objectName or another property to your state to check your condition. property bool isAnchors: myObj.states.find(function(s){ return s.name == myObj.state; }).myPropertyBool; State { property bool myPropertyBool: true // put true when you need it } Not sure if the Anchors is an attachement object, not sure you can probe it directly unless you seek into the Object children to find Attachment object of any kind, else you might want to check if you can reach the anchors property: property bool isAnchors: fetchAnchors(myObj) function fetchAnchors(o) { return o && o.anchors && o.anchors.top; // anchors cannot be null, only undefined, so the if value should work } From: Interest on behalf of Shawn Rutledge Sent: April 6, 2018 8:21 AM To: interest@qt-project.org Subject: Re: [Interest] How to determine whether QML item is anchored? But I wanted to query anchors at runtime once too, a few years ago; I think I’ve forgotten why. > On 6 Apr 2018, at 13:58, Mitch Curtis wrote: > > https://bugreports.qt.io/browse/QTBUG-66264 is semi-related to this, or at > least explains why we can’t really return null if they’re not set. > > Without having more information about your use case, it seems like quite a > corner case. > > From: Alexander Ivash [mailto:elder...@gmail.com] > Sent: Friday, 6 April 2018 1:41 PM > To: Mitch Curtis > Cc: interest@qt-project.org > Subject: Re: [Interest] How to determine whether QML item is anchored? > > Thanks, I'm aware of this, but this is a bit different.. Would be great to > get ability to compare against something like anchors.defaultLeft or > anchors.NoAnchor in future. > > Sent from Mailspring, the best free email app for work > On Apr 6 2018, at 2:38 pm, Mitch Curtis wrote: > > I’m not sure if it helps in your situation, but perhaps you could take a look > at AnchorChanges: > > > > http://doc.qt.io/qt-5/qml-qtquick-anchorchanges.html > > > > When the item is in an “anchored” state: > > > > states: [ > > State { > > name: "anchored" > > > > AnchorChanges { > > target: myRect > > anchors.top: window.top > > anchors.bottom: window.bottom > > } > > PropertyChanges { > > target: myRect > > color: "green" > > } > > }, > > State { > > name: "not-anchored" > > > > AnchorChanges { > > target: myRect > > anchors.top: undefined > > anchors.bottom: undefined > > } > > > > PropertyChanges { > > target: myRect > > color: "red" > > } > > } > > ] > > > > This assumes that you have control over the anchors, though. > > > > From: Alexander Ivash [mailto:elder...@gmail.com] > Sent: Friday, 6 April 2018 1:23 PM > To: Mitch Curtis > Cc: interest@qt-project.org > Subject: Re: [Interest] How to determine whether QML item is anchored? > > > Let's say I'm trying to make the logic like this: "If parent component is > anchored, make a child green, otherwise make it red" > > > Sent from Mailspring, the best free email app for work > On Apr 6 2018, at 2:20 pm, Mitch Curtis wrote: > > > What are you trying to do? > > > > > > From: Interest [mailto:interest-bounces+mitch.curtis=qt...@qt-project.org] On > Behalf Of Alexander Ivash > Sent: Friday, 6 April 2018 11:40 AM > To: interest@qt-project.org > Subject: [Interest] How to determine whether QML item is anchored? > > > > What I'm missing? It seems like even not anchored item has > anchors.right/left/top/bottom set, so it is not possible to compare with > 'undefined' or something. Of course introducing change handler allows to > track moment of anchoring (although still no way to track un-anchoring), but > this is a bit ugly and not 'Qt-way'. > > > > Sent from Mailspring, the best free email app for work > > ___ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] How to determine whether QML item is anchored?
But I wanted to query anchors at runtime once too, a few years ago; I think I’ve forgotten why. > On 6 Apr 2018, at 13:58, Mitch Curtis wrote: > > https://bugreports.qt.io/browse/QTBUG-66264 is semi-related to this, or at > least explains why we can’t really return null if they’re not set. > > Without having more information about your use case, it seems like quite a > corner case. > > From: Alexander Ivash [mailto:elder...@gmail.com] > Sent: Friday, 6 April 2018 1:41 PM > To: Mitch Curtis > Cc: interest@qt-project.org > Subject: Re: [Interest] How to determine whether QML item is anchored? > > Thanks, I'm aware of this, but this is a bit different.. Would be great to > get ability to compare against something like anchors.defaultLeft or > anchors.NoAnchor in future. > > Sent from Mailspring, the best free email app for work > On Apr 6 2018, at 2:38 pm, Mitch Curtis wrote: > > I’m not sure if it helps in your situation, but perhaps you could take a look > at AnchorChanges: > > > > http://doc.qt.io/qt-5/qml-qtquick-anchorchanges.html > > > > When the item is in an “anchored” state: > > > > states: [ > > State { > > name: "anchored" > > > > AnchorChanges { > > target: myRect > > anchors.top: window.top > > anchors.bottom: window.bottom > > } > > PropertyChanges { > > target: myRect > > color: "green" > > } > > }, > > State { > > name: "not-anchored" > > > > AnchorChanges { > > target: myRect > > anchors.top: undefined > > anchors.bottom: undefined > > } > > > > PropertyChanges { > > target: myRect > > color: "red" > > } > > } > > ] > > > > This assumes that you have control over the anchors, though. > > > > From: Alexander Ivash [mailto:elder...@gmail.com] > Sent: Friday, 6 April 2018 1:23 PM > To: Mitch Curtis > Cc: interest@qt-project.org > Subject: Re: [Interest] How to determine whether QML item is anchored? > > > Let's say I'm trying to make the logic like this: "If parent component is > anchored, make a child green, otherwise make it red" > > > Sent from Mailspring, the best free email app for work > On Apr 6 2018, at 2:20 pm, Mitch Curtis wrote: > > > What are you trying to do? > > > > > > From: Interest [mailto:interest-bounces+mitch.curtis=qt...@qt-project.org] On > Behalf Of Alexander Ivash > Sent: Friday, 6 April 2018 11:40 AM > To: interest@qt-project.org > Subject: [Interest] How to determine whether QML item is anchored? > > > > What I'm missing? It seems like even not anchored item has > anchors.right/left/top/bottom set, so it is not possible to compare with > 'undefined' or something. Of course introducing change handler allows to > track moment of anchoring (although still no way to track un-anchoring), but > this is a bit ugly and not 'Qt-way'. > > > > Sent from Mailspring, the best free email app for work > > ___ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] How to determine whether QML item is anchored?
https://bugreports.qt.io/browse/QTBUG-66264 is semi-related to this, or at least explains why we can’t really return null if they’re not set. Without having more information about your use case, it seems like quite a corner case. From: Alexander Ivash [mailto:elder...@gmail.com] Sent: Friday, 6 April 2018 1:41 PM To: Mitch Curtis Cc: interest@qt-project.org Subject: Re: [Interest] How to determine whether QML item is anchored? Thanks, I'm aware of this, but this is a bit different.. Would be great to get ability to compare against something like anchors.defaultLeft<https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/0?redirect=anchors.defaultLeft&recipient=bWl0Y2guY3VydGlzQHF0Lmlv> or anchors.NoAnchor<https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/1?redirect=anchors.NoAnchor&recipient=bWl0Y2guY3VydGlzQHF0Lmlv> in future. Sent from Mailspring<https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/2?redirect=https%3A%2F%2Fgetmailspring.com%2F&recipient=bWl0Y2guY3VydGlzQHF0Lmlv>, the best free email app for work On Apr 6 2018, at 2:38 pm, Mitch Curtis mailto:mitch.cur...@qt.io>> wrote: I’m not sure if it helps in your situation, but perhaps you could take a look at AnchorChanges: http://doc.qt.io/qt-5/qml-qtquick-anchorchanges.html<https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/3?redirect=http%3A%2F%2Fdoc.qt.io%2Fqt-5%2Fqml-qtquick-anchorchanges.html&recipient=bWl0Y2guY3VydGlzQHF0Lmlv> When the item is in an “anchored” state: states: [ State { name: "anchored" AnchorChanges { target: myRect anchors.top: window.top anchors.bottom: window.bottom } PropertyChanges { target: myRect color: "green" } }, State { name: "not-anchored" AnchorChanges { target: myRect anchors.top: undefined anchors.bottom: undefined } PropertyChanges { target: myRect color: "red" } } ] This assumes that you have control over the anchors, though. From: Alexander Ivash [mailto:elder...@gmail.com] Sent: Friday, 6 April 2018 1:23 PM To: Mitch Curtis mailto:mitch.cur...@qt.io>> Cc: interest@qt-project.org<mailto:interest@qt-project.org> Subject: Re: [Interest] How to determine whether QML item is anchored? Let's say I'm trying to make the logic like this: "If parent component is anchored, make a child green, otherwise make it red" Sent from Mailspring<https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/4?redirect=https%3A%2F%2Flink.getmailspring.com%2Flink%2F1523013678.local-18836154-ab75-v1.2.1-7e7447b6%40getmailspring.com%2F0%3Fredirect%3Dhttps%253A%252F%252Fgetmailspring.com%252F%26recipient%3DbWl0Y2guY3VydGlzQHF0Lmlv&recipient=bWl0Y2guY3VydGlzQHF0Lmlv>, the best free email app for work On Apr 6 2018, at 2:20 pm, Mitch Curtis mailto:mitch.cur...@qt.io>> wrote: What are you trying to do? From: Interest [mailto:interest-bounces+mitch.curtis=qt...@qt-project.org] On Behalf Of Alexander Ivash Sent: Friday, 6 April 2018 11:40 AM To: interest@qt-project.org<mailto:interest@qt-project.org> Subject: [Interest] How to determine whether QML item is anchored? What I'm missing? It seems like even not anchored item has anchors.right/left/top/bottom set, so it is not possible to compare with 'undefined' or something. Of course introducing change handler allows to track moment of anchoring (although still no way to track un-anchoring), but this is a bit ugly and not 'Qt-way'. Sent from Mailspring<https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/5?redirect=https%3A%2F%2Flink.getmailspring.com%2Flink%2F1523013678.local-18836154-ab75-v1.2.1-7e7447b6%40getmailspring.com%2F1%3Fredirect%3Dhttps%253A%252F%252Flink.getmailspring.com%252Flink%252F1523007448.local-615ef209-6912-v1.2.1-7e7447b6%2540getmailspring.com%252F0%253Fredirect%253Dhttps%25253A%25252F%25252Fgetmailspring.com%25252F%2526recipient%253DaW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%25253D%26recipient%3DbWl0Y2guY3VydGlzQHF0Lmlv&recipient=bWl0Y2guY3VydGlzQHF0Lmlv>, the best free email app for work [Open Tracking] ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] How to determine whether QML item is anchored?
Thanks, I'm aware of this, but this is a bit different.. Would be great to get ability to compare against something like anchors.defaultLeft (https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/0?redirect=anchors.defaultLeft&recipient=aW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%3D) or anchors.NoAnchor (https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/1?redirect=anchors.NoAnchor&recipient=aW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%3D) in future. Sent from Mailspring (https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/2?redirect=https%3A%2F%2Fgetmailspring.com%2F&recipient=aW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%3D), the best free email app for work On Apr 6 2018, at 2:38 pm, Mitch Curtis wrote: > > I’m not sure if it helps in your situation, but perhaps you could take a look > at AnchorChanges: > > http://doc.qt.io/qt-5/qml-qtquick-anchorchanges.html > (https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/3?redirect=http%3A%2F%2Fdoc.qt.io%2Fqt-5%2Fqml-qtquick-anchorchanges.html&recipient=aW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%3D) > > When the item is in an “anchored” state: > > states: [ > State { > name: "anchored" > > AnchorChanges { > target: myRect > anchors.top: window.top > anchors.bottom: window.bottom > } > PropertyChanges { > target: myRect > color: "green" > } > }, > State { > name: "not-anchored" > > AnchorChanges { > target: myRect > anchors.top: undefined > anchors.bottom: undefined > } > > PropertyChanges { > target: myRect > color: "red" > } > } > ] > > This assumes that you have control over the anchors, though. > > From: Alexander Ivash [mailto:elder...@gmail.com] > Sent: Friday, 6 April 2018 1:23 PM > To: Mitch Curtis > Cc: interest@qt-project.org > Subject: Re: [Interest] How to determine whether QML item is anchored? > > > > > > Let's say I'm trying to make the logic like this: "If parent component is > anchored, make a child green, otherwise make it red" > > > Sent from Mailspring > (https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/4?redirect=https%3A%2F%2Flink.getmailspring.com%2Flink%2F1523013678.local-18836154-ab75-v1.2.1-7e7447b6%40getmailspring.com%2F0%3Fredirect%3Dhttps%253A%252F%252Fgetmailspring.com%252F%26recipient%3DbWl0Y2guY3VydGlzQHF0Lmlv&recipient=aW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%3D), > the best free email app for work > On Apr 6 2018, at 2:20 pm, Mitch Curtis wrote: > > > > > > > What are you trying to do? > > > > > > > > From: Interest [mailto:interest-bounces+mitch.curtis=qt...@qt-project.org] > > On Behalf Of Alexander Ivash > > Sent: Friday, 6 April 2018 11:40 AM > > > > To: interest@qt-project.org > > > > Subject: [Interest] How to determine whether QML item is anchored? > > > > > > > > > > > > > > > > > > What I'm missing? It seems like even not anchored item has > > anchors.right/left/top/bottom set, so it is not possible to compare with > > 'undefined' or something. Of course introducing change handler allows to > > track moment of anchoring (although still no way to track un-anchoring), > > but this is a bit ugly and not 'Qt-way'. > > > > > > > > > > Sent from Mailspring > > (https://link.getmailspring.com/link/1523014719.local-23d3901e-507d-v1.2.1-7e744...@getmailspring.com/5?redirect=https%3A%2F%2Flink.getmailspring.com%2Flink%2F1523013678.local-18836154-ab75-v1.2.1-7e7447b6%40getmailspring.com%2F1%3Fredirect%3Dhttps%253A%252F%252Flink.getmailspring.com%252Flink%252F1523007448.local-615ef209-6912-v1.2.1-7e7447b6%2540getmailspring.com%252F0%253Fredirect%253Dhttps%25253A%25252F%25252Fgetmailspring.com%25252F%2526recipient%253DaW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%25253D%26recipient%3DbWl0Y2guY3VydGlzQHF0Lmlv&recipient=aW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%3D), > > the best free email app for work___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] How to determine whether QML item is anchored?
I’m not sure if it helps in your situation, but perhaps you could take a look at AnchorChanges: http://doc.qt.io/qt-5/qml-qtquick-anchorchanges.html When the item is in an “anchored” state: states: [ State { name: "anchored" AnchorChanges { target: myRect anchors.top: window.top anchors.bottom: window.bottom } PropertyChanges { target: myRect color: "green" } }, State { name: "not-anchored" AnchorChanges { target: myRect anchors.top: undefined anchors.bottom: undefined } PropertyChanges { target: myRect color: "red" } } ] This assumes that you have control over the anchors, though. From: Alexander Ivash [mailto:elder...@gmail.com] Sent: Friday, 6 April 2018 1:23 PM To: Mitch Curtis Cc: interest@qt-project.org Subject: Re: [Interest] How to determine whether QML item is anchored? Let's say I'm trying to make the logic like this: "If parent component is anchored, make a child green, otherwise make it red" Sent from Mailspring<https://link.getmailspring.com/link/1523013678.local-18836154-ab75-v1.2.1-7e744...@getmailspring.com/0?redirect=https%3A%2F%2Fgetmailspring.com%2F&recipient=bWl0Y2guY3VydGlzQHF0Lmlv>, the best free email app for work On Apr 6 2018, at 2:20 pm, Mitch Curtis wrote: What are you trying to do? From: Interest [mailto:interest-bounces+mitch.curtis=qt...@qt-project.org] On Behalf Of Alexander Ivash Sent: Friday, 6 April 2018 11:40 AM To: interest@qt-project.org Subject: [Interest] How to determine whether QML item is anchored? What I'm missing? It seems like even not anchored item has anchors.right/left/top/bottom set, so it is not possible to compare with 'undefined' or something. Of course introducing change handler allows to track moment of anchoring (although still no way to track un-anchoring), but this is a bit ugly and not 'Qt-way'. Sent from Mailspring<https://link.getmailspring.com/link/1523013678.local-18836154-ab75-v1.2.1-7e744...@getmailspring.com/1?redirect=https%3A%2F%2Flink.getmailspring.com%2Flink%2F1523007448.local-615ef209-6912-v1.2.1-7e7447b6%40getmailspring.com%2F0%3Fredirect%3Dhttps%253A%252F%252Fgetmailspring.com%252F%26recipient%3DaW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%253D&recipient=bWl0Y2guY3VydGlzQHF0Lmlv>, the best free email app for work [Image removed by sender. Open Tracking] [Image removed by sender. Open Tracking] ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] How to determine whether QML item is anchored?
Let's say I'm trying to make the logic like this: "If parent component is anchored, make a child green, otherwise make it red" Sent from Mailspring (https://link.getmailspring.com/link/1523013678.local-18836154-ab75-v1.2.1-7e744...@getmailspring.com/0?redirect=https%3A%2F%2Fgetmailspring.com%2F&recipient=aW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%3D), the best free email app for work On Apr 6 2018, at 2:20 pm, Mitch Curtis wrote: > > What are you trying to do? > > From: Interest [mailto:interest-bounces+mitch.curtis=qt...@qt-project.org] On > Behalf Of Alexander Ivash > Sent: Friday, 6 April 2018 11:40 AM > To: interest@qt-project.org > Subject: [Interest] How to determine whether QML item is anchored? > > > > > > What I'm missing? It seems like even not anchored item has > anchors.right/left/top/bottom set, so it is not possible to compare with > 'undefined' or something. Of course introducing change handler allows to > track moment of anchoring (although still no way to track un-anchoring), but > this is a bit ugly and not 'Qt-way'. > > > Sent from Mailspring > (https://link.getmailspring.com/link/1523013678.local-18836154-ab75-v1.2.1-7e744...@getmailspring.com/1?redirect=https%3A%2F%2Flink.getmailspring.com%2Flink%2F1523007448.local-615ef209-6912-v1.2.1-7e7447b6%40getmailspring.com%2F0%3Fredirect%3Dhttps%253A%252F%252Fgetmailspring.com%252F%26recipient%3DaW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%253D&recipient=aW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%3D), > the best free email app for work > > > > > > > ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] How to determine whether QML item is anchored?
What are you trying to do? From: Interest [mailto:interest-bounces+mitch.curtis=qt...@qt-project.org] On Behalf Of Alexander Ivash Sent: Friday, 6 April 2018 11:40 AM To: interest@qt-project.org Subject: [Interest] How to determine whether QML item is anchored? What I'm missing? It seems like even not anchored item has anchors.right/left/top/bottom set, so it is not possible to compare with 'undefined' or something. Of course introducing change handler allows to track moment of anchoring (although still no way to track un-anchoring), but this is a bit ugly and not 'Qt-way'. Sent from Mailspring<https://link.getmailspring.com/link/1523007448.local-615ef209-6912-v1.2.1-7e744...@getmailspring.com/0?redirect=https%3A%2F%2Fgetmailspring.com%2F&recipient=aW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%3D>, the best free email app for work [Open Tracking] ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
[Interest] How to determine whether QML item is anchored?
What I'm missing? It seems like even not anchored item has anchors.right/left/top/bottom set, so it is not possible to compare with 'undefined' or something. Of course introducing change handler allows to track moment of anchoring (although still no way to track un-anchoring), but this is a bit ugly and not 'Qt-way'. Sent from Mailspring (https://link.getmailspring.com/link/1523007448.local-615ef209-6912-v1.2.1-7e744...@getmailspring.com/0?redirect=https%3A%2F%2Fgetmailspring.com%2F&recipient=aW50ZXJlc3RAcXQtcHJvamVjdC5vcmc%3D), the best free email app for work___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest