Results 1 to 2 of 2

Thread: QtScript: Iterate over all custom QScriptValues

  1. #1
    Join Date
    Jun 2009
    Posts
    13
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Lightbulb QtScript: Iterate over all custom QScriptValues

    Hello,
    again i have searched the forums and the internet, but didn't find a satisfying answer to my problem.

    I'm programming a system in which the user is able to add own Objects, which are evaluated by a QScriptEngine.
    An example code which could be created is this:
    Qt Code:
    1. my_parameter = new Object();
    2. my_parameter.name = "My new Parameter";
    3. my_parameter.value = "10";
    4. my_parameter.unit = "km";
    To copy to clipboard, switch view to plain text mode 

    Now the problem: If the user has created several of this parameters I need to track them to read all relevant properties.
    I intended to do this with QScriptValueIterator, in which i would iterate over all values and if they have a specially-named parameter which they all share i know this is one of the objects i want.
    I was expecting custom objects to be properties of the QScriptEngines globalObject(), but it seems that is not the case.
    Do you know a way to iterate over all properties which were created so i can sort out the ones which i need?

    If you know a documentation where i can find the answer myself i'm perfectly happy, but the short QScriptEngine description was not of much help.

  2. #2
    Join Date
    Jun 2009
    Posts
    13
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtScript: Iterate over all custom QScriptValues

    Solved the problem by creating a new Object as a property of the globalObject() onto which all user-created parameters are put.

Similar Threads

  1. Replies: 2
    Last Post: 18th June 2013, 10:31
  2. iterate through QHash
    By rosenth in forum Qt Programming
    Replies: 3
    Last Post: 23rd May 2010, 07:55
  3. Replies: 0
    Last Post: 25th November 2009, 07:46
  4. How to iterate QMap twice
    By sophister in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2009, 16:59
  5. Iterate the QListWidget
    By vishal.chauhan in forum Newbie
    Replies: 1
    Last Post: 26th February 2007, 07:51

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.