Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Qt and QtPy in one program
Forum Updated to NodeBB v4.3 + New Features

Qt and QtPy in one program

Scheduled Pinned Locked Moved Unsolved Language Bindings
4 Posts 4 Posters 1.5k Views 2 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.
  • F Offline
    F Offline
    Freddykong
    wrote on last edited by
    #1

    Hi everyone, I am new to Qt and I am actually looking for informations about Qt before using it for my project.
    I would like to know if it is possible to use QT ( C++ ) and QtPy ( Python ) languages in the same program's code?
    Is it possible to call a pythons script (.py) directly from my code in Qt?

    Thanks

    JonBJ Pablo J. RoginaP 2 Replies Last reply
    0
    • F Freddykong

      Hi everyone, I am new to Qt and I am actually looking for informations about Qt before using it for my project.
      I would like to know if it is possible to use QT ( C++ ) and QtPy ( Python ) languages in the same program's code?
      Is it possible to call a pythons script (.py) directly from my code in Qt?

      Thanks

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Freddykong
      I think you need to clarify just what/why you are trying to do which would require both Qt for C++ and Qt for Python to be run inside a project? It's usual to need just one or the other.

      Is it possible to call a pythons script (.py) directly from my code in Qt?

      You can always run any kind of sub-process, including running some standalone Python script/code, via QProcess::start(). But if that script is intended to access things inside your actual parent program, or use Qt calls to access Qt objects/UI in the calling program, that is a different matter....

      1 Reply Last reply
      0
      • F Freddykong

        Hi everyone, I am new to Qt and I am actually looking for informations about Qt before using it for my project.
        I would like to know if it is possible to use QT ( C++ ) and QtPy ( Python ) languages in the same program's code?
        Is it possible to call a pythons script (.py) directly from my code in Qt?

        Thanks

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @Freddykong could you please describe what could be an use case for having both Qt (C++) and Qt (Python) sources at the same application?

        In any case, instead of running the Python script as a separate/child process as suggested by @JonB you may want to embed a Python interpreter in your C++ code

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • CristianMaureiraC Offline
          CristianMaureiraC Offline
          CristianMaureira
          wrote on last edited by
          #4

          I don't know if I got the question right,
          but the kind of interaction you describe could be possible by "extending" and existing Qt/C++ application to use Qt/Python code.

          Take a look at this example: https://code.qt.io/cgit/pyside/pyside-setup.git/tree/examples/scriptableapplication
          There, there is a Qt/C++ Window that shows some Python code which you can run and interact with the Qt/C++ object itself.

          Please be aware that many things need to be consider, and that you must handle the embedded Python and generate Python bindings for your Qt/C++ potion of code that you want to interact with.

          Another use-case which was based on that example, is the research that is currently on-going regarding extending QtCreator with Python:
          https://blog.qt.io/blog/2018/08/15/python-extensions/

          I hope those cases are in the same direction as your question.

          1 Reply Last reply
          1

          • Login

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