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. Vector3d type as property in QML (2D)
Forum Updated to NodeBB v4.3 + New Features

Vector3d type as property in QML (2D)

Scheduled Pinned Locked Moved QML and Qt Quick
9 Posts 3 Posters 5.7k 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.
  • Q Offline
    Q Offline
    qtnext
    wrote on 17 Apr 2011, 21:41 last edited by
    #1

    Hi,

    Is it possible to use vector3d as property in an item ? It seems it don't works. Is it possible to register QVector3D to use it as property in items ?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stephen
      wrote on 17 Apr 2011, 23:13 last edited by
      #2

      Yes it works fine. You can use it in the axis property of a Rotation element and even animate that:

      @
      import QtQuick 1.0

      Item {
      width : 400
      height : 400
      Rectangle {
      x : 100
      y : 100
      width : 100
      height : 100
      color : "lightsteelblue"
      transform : Rotation {
      angle : 45
      // axis : Qt.vector3d(1, 0, 0)
      SequentialAnimation on axis {
      Vector3dAnimation {
      from : Qt.vector3d(0.3, 0.3, 0.3)
      to : Qt.vector3d(0, 0.6, 0.6)
      duration : 1000
      }
      Vector3dAnimation {
      from : Qt.vector3d(0, 0.6, 0.6)
      to : Qt.vector3d(0.3, 0.3, 0.3)
      duration : 1000
      }
      loops : Animation.Infinite
      }
      }
      }
      }
      @

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qtnext
        wrote on 18 Apr 2011, 10:46 last edited by
        #3

        I wants to have this for example :
        @
        Item{

        property vector3d value

        Text{
        text: value.x
        }

        }

        @

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mbrasser
          wrote on 18 Apr 2011, 23:12 last edited by
          #4

          Hi,

          You can't directly declare properties of type vector3d, but you should be able to do something like this:

          @
          property variant value: Qt.vector3d(1,0,0)
          @

          Regards,
          Michael

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            qtnext
            wrote on 19 Apr 2011, 06:14 last edited by
            #5

            ok so it's not possible to have a binded property in qml. There is no way to add new type as binded property ? Is it hardcoded in QML?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mbrasser
              wrote on 20 Apr 2011, 03:07 last edited by
              #6

              The types that can be used like:

              @property <type> <name>@

              in QML are currently hard-coded. You can see the list of supported types at http://doc.qt.nokia.com/4.7/qml-extending-types.html#supported-property-types.

              1 Reply Last reply
              0
              • Q Offline
                Q Offline
                qtnext
                wrote on 20 Apr 2011, 06:18 last edited by
                #7

                thanks ... reading the documentation, I understand that I can use variant type ... so I can declare a variant property and use vector3 ?

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mbrasser
                  wrote on 20 Apr 2011, 23:09 last edited by
                  #8

                  Yes, you should be able to use a variant with vector3d as described earlier, i.e:

                  @property variant value: Qt.vector3d(1,0,0)@

                  Is that sufficient for your needs?

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    qtnext
                    wrote on 21 Apr 2011, 06:20 last edited by
                    #9

                    It seems that it works ... I have to check if it works with my C++ model for Qvector3D property binding

                    1 Reply Last reply
                    0

                    1/9

                    17 Apr 2011, 21:41

                    • Login

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