Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Want to pass a QDomDocument to an embedded Python script
Forum Updated to NodeBB v4.3 + New Features

Want to pass a QDomDocument to an embedded Python script

Scheduled Pinned Locked Moved Unsolved Qt for Python
8 Posts 3 Posters 438 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.
  • K Offline
    K Offline
    kesterpm
    wrote on 26 Jan 2023, 13:29 last edited by
    #1

    I'm trying to pass a QDomDocument to an embedded Python script. I believe I can use Py_BuildValue, but I can't find any good examples that show you how to pass your own object. Cany anyone point me to some good examples of this?

    J 1 Reply Last reply 26 Jan 2023, 13:53
    0
    • K kesterpm
      26 Jan 2023, 13:29

      I'm trying to pass a QDomDocument to an embedded Python script. I believe I can use Py_BuildValue, but I can't find any good examples that show you how to pass your own object. Cany anyone point me to some good examples of this?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 26 Jan 2023, 13:53 last edited by
      #2

      @kesterpm said in Want to pass a QDomDocument to an embedded Python script:

      embedded Python script

      In what way embedded? Is your app written in C++ and you're running a Python script inside your app?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kesterpm
        wrote on 26 Jan 2023, 14:18 last edited by
        #3

        Yes, my C++ app will look for python scripts to load. Events are customizable and will call a Python method if it exists. Basically the app allows you to extend it's functionality using Python.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 26 Jan 2023, 19:30 last edited by
          #4

          Hi,

          Are you planning to use PySide to manipulate your QDomDocument on the python side ?

          If so, this example might be a starting point.

          Hope it helps

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

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kesterpm
            wrote on 26 Jan 2023, 19:47 last edited by
            #5

            Yes, that code has been written and tested. The trick is passing this custom datatype between c++ and python. I could send a string over and import it into a qdomdocument, but that seems really inefficient.

            K 1 Reply Last reply 16 Feb 2023, 17:56
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 26 Jan 2023, 19:56 last edited by
              #6

              Maybe the code injection part will offer some insight for 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

              K 1 Reply Last reply 16 Feb 2023, 17:58
              0
              • K kesterpm
                26 Jan 2023, 19:47

                Yes, that code has been written and tested. The trick is passing this custom datatype between c++ and python. I could send a string over and import it into a qdomdocument, but that seems really inefficient.

                K Offline
                K Offline
                kesterpm
                wrote on 16 Feb 2023, 17:56 last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0
                • S SGaist
                  26 Jan 2023, 19:56

                  Maybe the code injection part will offer some insight for your use case.

                  K Offline
                  K Offline
                  kesterpm
                  wrote on 16 Feb 2023, 17:58 last edited by
                  #8

                  @SGaist Yeah it seems like you need to create a wrapper in C++ somehow. I would think a wrapper exists already, but I can't find any good examples. I'm pretty close to just sending it as a string to python, then converting it to a QDomDocument in the embedded python. Thanks for pointing me to those documents.

                  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