Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Script parser[solved]

    General and Desktop
    2
    6
    1946
    Loading More Posts
    • 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.
    • R
      Ruzik last edited by

      Hellow, i need to create script math parser, for example i have this string: 1+2+3, and i want to find answer with scripts, how can i do it?
      I try:
      @ QScriptEngine scriptEngine;
      QScriptValue scriptLineEdit = scriptEngine.newQObject(lineEdit);
      scriptEngine.globalObject().setProperty("lineEdit", scriptLineEdit);
      scriptEngine.evaluate("var answer = lineEdit.txt;" //<---
      "lineEdit.text = answer;");@
      How can I make so that the line was interpreted as a command, not a string?

      1 Reply Last reply Reply Quote 0
      • D
        DenisKormalev last edited by

        Use eval() function.

        1 Reply Last reply Reply Quote 0
        • R
          Ruzik last edited by

          Could you tell me more about this function, as assistant about i found nothing it

          1 Reply Last reply Reply Quote 0
          • D
            DenisKormalev last edited by

            It is js function, you can read more about it "here":http://www.w3schools.com/jsref/jsref_eval.asp

            1 Reply Last reply Reply Quote 0
            • R
              Ruzik last edited by

              It is work, thank you for your help!

              1 Reply Last reply Reply Quote 0
              • D
                DenisKormalev last edited by

                You are welcome, please add [solved] to your post title

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post