Results 1 to 8 of 8

Thread: QTScript - getting the name of a QScriptValue

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17
    Thanked 90 Times in 88 Posts

    Default Re: QTScript - getting the name of a QScriptValue

    Hi there. So as I suspected you have one script which calls another dynamically created one. In the process of creating that other script you insert the name of the (global!) variable which is to be worked upon. Now you want this nameinsertion to work without explicitely passing the name to insert!

    I think what you want to achieve is exactly why arguments to functions have been introduced. That you can call the same function with different values (or pointer to objects to be worked upon).

    Your dynamic creation has one other major flaw: speed. Each time the simulation is started for a different simulationobject you need to reevaluate the generated simulationscript. If you were to use an argument you could just call the function directly.

    Are you perhaps using the name of the object in your simulation script to switch between different cases? In that case I suggest an OOP approach. Just put every specialization into a class-member function and construct a proper inheritance-tree.

    Now that we have nailed your question, maybe somebody else has a solution? Even so I would strongly recommend not using it in terms of code serviceability :->

    Johannes

  2. The following user says thank you to JohannesMunk for this useful post:

    android_ (28th October 2009)

Similar Threads

  1. QtScript: default constructor question
    By QPlace in forum Qt Programming
    Replies: 1
    Last Post: 22nd October 2009, 19:36
  2. QtScript evaluation question
    By QPlace in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2009, 03:46
  3. QScriptValue with simple typedef types
    By JohannesMunk in forum Newbie
    Replies: 9
    Last Post: 14th May 2009, 15:07
  4. QtScript Binding problem with QWidget
    By zack in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2009, 09:38
  5. QtScript Q_ENUM problem
    By oc2k1 in forum Qt Programming
    Replies: 0
    Last Post: 14th May 2007, 16:07

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
  •  
Qt is a trademark of The Qt Company.