Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved python binding on Qt application

    General and Desktop
    5
    9
    2159
    Loading More Posts
    • 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
      sigmind last edited by sigmind

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 2
        • S
          sigmind last edited by

          Thanks. I'll check out

          1 Reply Last reply Reply Quote 0
          • W
            wrosecrans last edited by

            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 Reply Quote 0
            • D
              Dariusz last edited by

              +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?

              jsulm 1 Reply Last reply Reply Quote 0
              • jsulm
                jsulm Lifetime Qt Champion @Dariusz last edited by

                @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 Reply Quote 0
                • D
                  Dariusz @jsulm last edited by

                  @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.

                  jsulm 1 Reply Last reply Reply Quote 0
                  • jsulm
                    jsulm Lifetime Qt Champion @Dariusz last edited by

                    @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 Reply Quote 0
                    • D
                      Dariusz @jsulm last edited by

                      @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 Reply Quote 0
                      • First post
                        Last post