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. How to clone QJSEngine?
Forum Update on Monday, May 27th 2025

How to clone QJSEngine?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qjsengine
5 Posts 3 Posters 433 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.
  • M Offline
    M Offline
    Merssedes
    wrote on 4 May 2024, 19:13 last edited by
    #1

    Given the instance of QJSEngine, how to create new instance with the same state?

    C 1 Reply Last reply 7 May 2024, 02:48
    0
    • M Merssedes
      4 May 2024, 19:13

      Given the instance of QJSEngine, how to create new instance with the same state?

      C Offline
      C Offline
      ChrisW67
      wrote on 7 May 2024, 02:48 last edited by
      #2

      @Merssedes I am not a QJSEngine user, but you cannot clone a QObject (by design). You would have to create a new object and manually configure it to match. I do not see a simple way to achieve this.

      M 1 Reply Last reply 7 May 2024, 15:39
      3
      • C ChrisW67
        7 May 2024, 02:48

        @Merssedes I am not a QJSEngine user, but you cannot clone a QObject (by design). You would have to create a new object and manually configure it to match. I do not see a simple way to achieve this.

        M Offline
        M Offline
        Merssedes
        wrote on 7 May 2024, 15:39 last edited by
        #3

        @ChrisW67 you mean if library accepts instance of QJSEngine, it can't create more of them? Cna you link me to any discussions related to this design choise?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 7 May 2024, 15:42 last edited by
          #4

          You can create several instances but you cannot copy them. Though AFAIK, there's usually no reason to have more than one. What is your use case ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply 7 May 2024, 19:58
          1
          • S SGaist
            7 May 2024, 15:42

            You can create several instances but you cannot copy them. Though AFAIK, there's usually no reason to have more than one. What is your use case ?

            M Offline
            M Offline
            Merssedes
            wrote on 7 May 2024, 19:58 last edited by
            #5

            @SGaist Multithreading with requirement of no interlocking. Because QJSEngine is not thread safe, the only way I see for now is to clone original prepared instance for each worker thread. Anything else requires syncronisation between threads, which means interlocking.

            1 Reply Last reply
            0

            5/5

            7 May 2024, 19:58

            • Login

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