Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. CreateObject initial properties
Forum Updated to NodeBB v4.3 + New Features

CreateObject initial properties

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mmlado
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      blam
      wrote on last edited by
      #2

      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().

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mmlado
        wrote on last edited by
        #3

        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).

        1 Reply Last reply
        0
        • B Offline
          B Offline
          blam
          wrote on last edited by
          #4

          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.)

          1 Reply Last reply
          0
          • D Offline
            D Offline
            drevil
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • B Offline
              B Offline
              blam
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved