Embedding the Python Interpreter in a Qt/C++ Application.
This repository demonstrates how to integrate Python directly into a Qt-based C++ application using the Python/C API. The code is developed step by step in my tutorial at ubuverse.com/embedding-the-python-interpreter-in-a-qt-application.
- Qt 6 (development libraries)
- Python 3 development headers
- C++ build tools
On Debian/Ubuntu-based systems, you can install everything with:
sudo apt install build-essential qtcreator qt6-base-dev python3-dev- Build and Run
- Open Qt Creator
- Open the project file from this repository
- Configure the project using a Qt 6 kit
- Build and run the application
The tutorial linked above explains each step in detail.
The Python script in python/compile.py is used to collect and compile the subset of Python's standard library required by your program and package it into a ZIP archive. This file must be distributed alongside the Qt application binary so the embedded Python interpreter can load the necessary modules at runtime. See the tutorial for more details.
GPL-3.0