Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Strict knowledge of subset of properties involved in a userdefined script
Forum Updated to NodeBB v4.3 + New Features

Strict knowledge of subset of properties involved in a userdefined script

Scheduled Pinned Locked Moved Language Bindings
1 Posts 1 Posters 1.2k 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.
  • L Offline
    L Offline
    laurent bauer
    wrote on 7 Aug 2012, 08:32 last edited by
    #1

    Hello,

    I've a QScriptvalue m_ParametersObject containing a set of properties/double P1,P2...Pn
    I want the user to define formula in a QTextEdit where a formula is a relation between a choice of parameters

    ex: Let the parametersObject contain p1..p5.
    The user defines the followinf formula in a textEdit : "p5 = p2+p4"
    I need to know that p2 and p4 are involved in the forumla and that p1 and p3 are not involved.

    @
    void AddFormulaDialog::formulaChanged() // textEdit slot
    {
    QString formula = ui->textEdit->toPlainText();
    QScriptEngine * engine = m_ParametersObject->engine();
    // m_ParametersObject is a QScriptValue, with parameters as properties p1, p2...pn
    QScriptContext * context = engine->pushContext();
    context->setActivationObject(*m_ParametersObject);
    QScriptValue res = engine->evaluate(formula);

    QPushButton * okButton = ui->buttonBox->button(QDialogButtonBox::Ok);
    okButton->setEnabled(!res.isError());
    
    engine->popContext(); 
    

    }
    @

    With this, I can get the analytical formula and the evaluation, but not the topological information: I don't know which parameters are actually involved int the relation.

    QScriptValueIterator doesn't help here:
    QScriptValueIterator it(*m_ParametersObject) gives me all properties of the context (not only of the formula)
    QScriptValueIterator it(res) gives nothing.

    Is there a way (even completely different), to strictly retrieve the set of properties involved in the interactively user defined formula?

    Note: I'm new to QtScript

    Thank you in advance
    Laurent

    1 Reply Last reply
    0

    1/1

    7 Aug 2012, 08:32

    • Login

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