<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Unable to make getOwnPropertyDescriptor working]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">I'm in trouble with Qt 5.7.0 and QML. I need to discover properties of some objects at runtime. No need to expand on the final goal the problem is elsewhere.</p>
<p dir="auto">I plan to use <strong>Object.getOwnPropertyDescriptor</strong> but I can't make it works as I want, after hours of test...</p>
<p dir="auto">Here is a POC in pure QML/JS</p>
<pre><code>import QtQuick 2.0

Item {

   id: myTest

   property int myProp : 1234


   function test() {
      console.log("_________________TEST_________________");
      console.log(Object.getOwnPropertyNames(myTest))
      console.log(myTest.hasOwnProperty("myProp"))
      console.log(Object.getOwnPropertyDescriptor(myTest, "myProp"));
      console.log("_________________TEST_________________");
   }
}
</code></pre>
<p dir="auto">In the log I get:</p>
<pre><code>qml: _________________TEST_________________
qml: [objectName,parent,data,resources,children,x,y,z,width,height,opacity,enabled,visible,visibleChildren,states,transitions,state,childrenRect,anchors,left,right,horizontalCenter,top,bottom,verticalCenter,baseline,baselineOffset,clip,focus,activeFocus,activeFocusOnTab,rotation,scale,transformOrigin,transformOriginPoint,transform,smooth,antialiasing,implicitWidth,implicitHeight,layer,myProp,objectNameChanged,childrenRectChanged,baselineOffsetChanged,stateChanged,focusChanged,activeFocusChanged,activeFocusOnTabChanged,parentChanged,transformOriginChanged,smoothChanged,antialiasingChanged,clipChanged,windowChanged,childrenChanged,opacityChanged,enabledChanged,visibleChanged,visibleChildrenChanged,rotationChanged,scaleChanged,xChanged,yChanged,widthChanged,heightChanged,zChanged,implicitWidthChanged,implicitHeightChanged,update,grabToImage,grabToImage,contains,mapToGlobal,mapFromGlobal,mapFromItem,mapToItem,forceActiveFocus,forceActiveFocus,nextItemInFocusChain,nextItemInFocusChain,childAt,myPropChanged,test]
qml: true
qml: undefined
qml: _________________TEST_________________
</code></pre>
<p dir="auto">According to the line "qml: true" the "hasOwnProperty('myProp')" find the property and say "true".</p>
<p dir="auto">But the next line trying to get the property descriptor return "undefined".</p>
<p dir="auto">The one who can solve my problem will be my Hero !</p>
]]></description><link>https://forum.qt.io/topic/77298/unable-to-make-getownpropertydescriptor-working</link><generator>RSS for Node</generator><lastBuildDate>Mon, 11 May 2026 11:39:19 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/77298.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 16 Mar 2017 17:27:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Unable to make getOwnPropertyDescriptor working on Thu, 16 Mar 2017 21:30:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">I don't know all the internals of QML but the "property" here matches Qt's property system which is not the same thing as JavaScript properties.</p>
<p dir="auto">I'd recommend bringing this question on the <a href="http://lists.qt-project.org/mailman/listinfo/interest" target="_blank" rel="noopener noreferrer nofollow ugc">interest mailing list</a>. You'll find there Qt's developers/maintainers. This forum is more user oriented.</p>
]]></description><link>https://forum.qt.io/post/382537</link><guid isPermaLink="true">https://forum.qt.io/post/382537</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 16 Mar 2017 21:30:59 GMT</pubDate></item></channel></rss>