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. QScriptEngine & QScriptContext How to use ?

QScriptEngine & QScriptContext How to use ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 336 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.
  • P Offline
    P Offline
    Pada_
    wrote on last edited by
    #1

    I am using Qt 5.4.

    When you write text in LineEdit or TextEdit and run the script, all text written in the widget is read and QScriptEngine-> evaluate () is executed.

    For example,

    var contents = "test"; And write
    After reading all with QTextStream, execute QScriptEngine-> evaluate ()

    You can set and use values for contents in the script.
    Once executed, I could get the value of at least test only for contents without the need for a separate declaration.

    QScriptEngine-> evaluate (), I thought that all previously written values were stored somewhere in the script, but when I ran another script file in the script, variables & functions were not saved.

    Is there a way to write a function in the called script when another script file is called in the script?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      You mean like this ?
      https://stackoverflow.com/questions/39128858/is-there-a-way-to-maintain-qt-script-context-environment-outside-of-qscriptengin
      Using pushContext

      P 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        You mean like this ?
        https://stackoverflow.com/questions/39128858/is-there-a-way-to-maintain-qt-script-context-environment-outside-of-qscriptengin
        Using pushContext

        P Offline
        P Offline
        Pada_
        wrote on last edited by
        #3

        @mrjj

        I do not put it in the global object separately.
        If you read the contents written in a text file and do scriptEngine-> evaluate (), it is automatically registered somewhere and you can use it without declaration.

        When calling another script from within the script, it seems that variables or functions in the other script cannot be saved.

        mrjjM 1 Reply Last reply
        0
        • P Pada_

          @mrjj

          I do not put it in the global object separately.
          If you read the contents written in a text file and do scriptEngine-> evaluate (), it is automatically registered somewhere and you can use it without declaration.

          When calling another script from within the script, it seems that variables or functions in the other script cannot be saved.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Pada_

          • When calling another script from within the script, it seems that variables or functions in the other script cannot be saved.

          What do you mean by saved?

          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