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 Update on Monday, May 27th 2025

python binding on Qt application

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 5 Posters 3.1k 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.
  • S Offline
    S Offline
    sigmind
    wrote on 9 Nov 2018, 15:29 last edited by sigmind 11 Sept 2018, 15:29
    #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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 9 Nov 2018, 22:01 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 10 Nov 2018, 10:15 last edited by
        #3

        Thanks. I'll check out

        1 Reply Last reply
        0
        • W Offline
          W Offline
          wrosecrans
          wrote on 10 Nov 2018, 19:05 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 11 Nov 2018, 01:40 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?

            J 1 Reply Last reply 12 Nov 2018, 06:25
            0
            • D Dariusz
              11 Nov 2018, 01:40

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

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 12 Nov 2018, 06:25 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 18 Nov 2018, 11:01
              0
              • J jsulm
                12 Nov 2018, 06:25

                @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 18 Nov 2018, 11:01 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.

                J 1 Reply Last reply 19 Nov 2018, 05:52
                0
                • D Dariusz
                  18 Nov 2018, 11:01

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

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 19 Nov 2018, 05:52 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 19 Nov 2018, 21:03
                  0
                  • J jsulm
                    19 Nov 2018, 05:52

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

                    D Offline
                    D Offline
                    Dariusz
                    wrote on 19 Nov 2018, 21:03 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

                    4/9

                    10 Nov 2018, 19:05

                    • Login

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