CreateObject initial properties
-
Hi.
New user here, sorry if I put this in the wrong place.
I'm trying to create objects dynamically and I found this instructions: "http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedynamicobjects.html":http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedynamicobjects.html
I have downloaded Qt SDK 1.1 beta from Nokia's page.
I tried the first (sprite) example. Problem is with:
@sprite = component.createObject(appWindow, {"x": 100, "y": 100});@
As I understand this should create a rectangle on position x = 100 and y = 100. But the rectangle is in the upper left corner at coordinates 0, 0.
If I add after that line
@sprite.x = 100;@
It will move the rectangle to the appropriate position.
So I don't know if it's a problem with my install, if the tutorial/example is wrong. Has anyone got this problem except me? -
The second argument to createObject() was added in QtQuick 1.1, which is not yet released, and is not part of the Qt SDK release. (The documentation under http://doc.qt.nokia.com/4.7-snapshot is taken directly from the repository and may document code that is not yet released.) The docs that are relevant to the Qt SDK version are available at
http://doc.qt.nokia.com/4.7.2/qdeclarativedynamicobjects.html
I'm sure the version of Qt Creator included with the Qt SDK has the correct version of the documentation as well.
So in the meantime, if you are not using QtQuick 1.1 directly from the Qt repository, you'll need to set the value using
@
sprite.x = 100
@instead of passing a second argument to createObject().
-
Thank you.
I thought the page I referred to was for base 4.7 (4.7.0).
I assume links with snapshot in it then show 4.7 latest development version, and we should rely on documentation with concrete version number (4.7.1). -
Yes, for API documentation it's best to read the documentation with concrete version numbers to check the features that have actually been released.
(I assumed http://doc.qt.nokia.com/4.7.2/ would work - I'm not sure why it redirects to http://doc.qt.nokia.com/4.7.1/ since 4.7.2 has already been released.)
-
So 4.7.2 is out and I still get the behavior the original posted had. The properly list 2nd argument doesn't appear to work in 4.7.2
-
The behavior described in the original post is not available in 4.7.2. QtQuick 1.1 is not part of the 4.7.2 or the Qt SDK release. You can check the documentation under http://doc.qt.nokia.com/latest for the docs relevant to the latest release.