Results 1 to 4 of 4

Thread: Accessing QML array from c++

  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 Accessing QML array from c++

    Hi,
    I have created an array in javascript in QML and filled it using javascript. This array contains QML objects.
    I need to access and update this array using c++ in my main QT function.
    I have searched alot but most of results talk about solution for accessing cpp objects defined in QML.
    What I need is vice versa.
    Would you please help?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing QML array from c++

    You need to locate a child object and then you will be able to modify a list.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  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: Accessing QML array from c++

    Thanks for your reply Spirit.
    But what I am looking for, is to access a java script array in QT main function using c++.
    I have defined following arrays in my QML.js
    .pragma library
    var dObjects1 = [];
    var dObjects2 = [];

    I need to access dObjects1 and dObjects2 in the main QT function.

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing QML array from c++

    It's not possibly. You should attach these object to QML objects properties.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. The following user says thank you to spirit for this useful post:

    alizadeh91 (5th September 2012)

Similar Threads

  1. Replies: 2
    Last Post: 7th April 2012, 23:30
  2. Replies: 2
    Last Post: 12th November 2010, 14:42
  3. declare an array of QSemaphore and array of slot functions
    By radeberger in forum Qt Programming
    Replies: 11
    Last Post: 2nd May 2010, 13:24
  4. Accessing array in both C++ and QtScript
    By abernat in forum Qt Programming
    Replies: 10
    Last Post: 6th September 2009, 22:21
  5. Accessing array (TABLE TYPE) in Stored Procedure from Qt
    By sureshbabu in forum Qt Programming
    Replies: 0
    Last Post: 26th September 2007, 11:36

Tags for this Thread

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.