Results 1 to 7 of 7

Thread: Access Object Created by javascript in qml

  1. #1
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Access Object Created by javascript in qml

    Hi friends..
    I've a question. I've a qml and i create some object dynamicaly in qml by javascript(createobject). How can i access to this object in qml? for example to allow to user drag it or bind some properties to it?
    thanks.

  2. #2
    Join Date
    Nov 2010
    Posts
    82
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Access Object Created by javascript in qml

    you can create a custom property :
    property QtObject dynamic_button

    and the save the result of createobject to this property.
    then use this property as you would with an item id.

  3. #3
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: Access Object Created by javascript in qml

    Thnaks Le_B
    How about if i create more dynamic_button and i want allow user to drag whichever he wants? Suppose i have an array in javascript which keeps all objects

  4. #4
    Join Date
    Nov 2010
    Posts
    82
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Access Object Created by javascript in qml

    then it shouldn't be an array or dynmic object but a model and a listview or gridview
    something like
    http://developer.qt.nokia.com/wiki/D...hin_a_GridView

  5. #5
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: Access Object Created by javascript in qml

    Thanks again.
    How can i implement drag and drop for a QtObject property which u mentioned?

  6. #6
    Join Date
    Nov 2010
    Posts
    82
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Access Object Created by javascript in qml

    the same way you would do it with static object.
    in the property case every property is like the id of the object

  7. #7
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: Access Object Created by javascript in qml

    Yeah that works thanks very much ...

Similar Threads

  1. Replies: 1
    Last Post: 18th October 2011, 08:32
  2. Replies: 9
    Last Post: 29th November 2010, 13:12
  3. Replies: 5
    Last Post: 23rd October 2010, 01:52
  4. Replies: 4
    Last Post: 9th February 2010, 18:08
  5. QtWebKit access HTML manipulated by javascript
    By rbp in forum Qt Programming
    Replies: 1
    Last Post: 19th September 2009, 03:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.