Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Script parser[solved]
QtWS25 Last Chance

Script parser[solved]

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.3k Views
  • 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 Offline
    R Offline
    Ruzik
    wrote on last edited by
    #1

    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
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      Use eval() function.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Ruzik
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Ruzik
            wrote on last edited by
            #5

            It is work, thank you for your help!

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DenisKormalev
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0

              • Login

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