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. python binding on Qt application
Forum Updated to NodeBB v4.3 + New Features

python binding on Qt application

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 5 Posters 3.1k 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.
  • S Offline
    S Offline
    sigmind
    wrote on last edited by sigmind
    #1

    Hello! I am planning to extend my Qt C++ application capabilities with additional python modules. I have heard of Qt for Python for binding qt GUI within python. But is the vice versa is possible?
    I mean, if I have a Qt C++ application, can I run python scripts within my C++ code? Is it possible ?

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

      Hi,

      Yes it is.

      You can check this article on how it is done.

      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
      2
      • S Offline
        S Offline
        sigmind
        wrote on last edited by
        #3

        Thanks. I'll check out

        1 Reply Last reply
        0
        • W Offline
          W Offline
          wrosecrans
          wrote on last edited by
          #4

          Check out PyBind11. I used to use Boost.Python for binding C++ code to expose it to Python, but Pybind11 is a lot more convenient to use and more modern.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dariusz
            wrote on last edited by
            #5

            +1 to pybind11, I started with it 2 weeks ago and I already have editor in qt & python coding environment & access between py-c++ stuff. Awesome So far!

            One thing I wonder, does any1 know if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?

            jsulmJ 1 Reply Last reply
            0
            • D Dariusz

              +1 to pybind11, I started with it 2 weeks ago and I already have editor in qt & python coding environment & access between py-c++ stuff. Awesome So far!

              One thing I wonder, does any1 know if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Dariusz said in python binding on Qt application:

              if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?

              Can you please explain what you mean? Send what to where? You can use QVector in PySide.

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

              D 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Dariusz said in python binding on Qt application:

                if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?

                Can you please explain what you mean? Send what to where? You can use QVector in PySide.

                D Offline
                D Offline
                Dariusz
                wrote on last edited by
                #7

                @jsulm said in python binding on Qt application:

                @Dariusz said in python binding on Qt application:

                if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?

                Can you please explain what you mean? Send what to where? You can use QVector in PySide.

                well if we use QT in c++ project, and Pybind11 + python&pyside2, it means that we have QVector on C++ side and QVector on PySide2 as well. As pybind11 only accepts native structures as far as I'm aware, if I wish to send shared_ptr<QVector<classData>> to PySide2, can I just send it as QVector or do I need to always convert it to std::vector and then send that? - or return. Its about accessing c++ data from python.

                jsulmJ 1 Reply Last reply
                0
                • D Dariusz

                  @jsulm said in python binding on Qt application:

                  @Dariusz said in python binding on Qt application:

                  if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?

                  Can you please explain what you mean? Send what to where? You can use QVector in PySide.

                  well if we use QT in c++ project, and Pybind11 + python&pyside2, it means that we have QVector on C++ side and QVector on PySide2 as well. As pybind11 only accepts native structures as far as I'm aware, if I wish to send shared_ptr<QVector<classData>> to PySide2, can I just send it as QVector or do I need to always convert it to std::vector and then send that? - or return. Its about accessing c++ data from python.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Dariusz Well, you need to send what pybind11 expects or can handle.

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

                  D 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @Dariusz Well, you need to send what pybind11 expects or can handle.

                    D Offline
                    D Offline
                    Dariusz
                    wrote on last edited by
                    #9

                    @jsulm yeah, bit of a bummer that cant pass QVector and I have to convert QVector > std::Vector>python Vector/does, actually not even sure if PySide2 offers QVector mhmm

                    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