- Qt Creator Manual
- Coding
- Developing Qt for Python Applications
- Qt Creator Manual 11.0.0

Using GitHub Copilot ◦ Editing MIME Types

# Developing Qt for Python Applications

Qt for Python enables you to use Qt 6 API in Python applications. You can use the PySide6 modules to gain access to individual Qt modules, such as Qt Core, Qt GUI, and Qt Widgets.

The following sections describe using Qt Creator for developing with Qt for Python:

- Creating Qt for Python Applications
- Setting Up PySide6
- Selecting the Python Interpreter
- Creating a Virtual Environment
- Using Python Interactive Shell
- Python Language Server
- Running Python Projects
- Specifying Run Settings for Python Projects
- PDB
- Launching the Debugger

For more information about developing with Qt for Python, including limitations, see Qt for Python.

## Setting Up PySide6

If you have not installed the required version of PySide6, Qt Creator prompts you to do so when you open a .py file.

Further, Qt Creator prompts you to install the Python language server that offers services such as code completion and annotations. Select Install to install PySide6 and the language server.

## Selecting the Python Interpreter

You select the initial Python interpreter when you use the Qt for Python Application wizard templates to create Python projects.

You can see the current Python interpreter on the Edit mode toolbar.

You can change the interpreter to use for a particular project in Projects > Run > Interpreter.

To see the available interpreters and choose another interpreter, select the current interpreter, and then select Manage Python Interpreters. Or, select Edit > Preferences > Python > Interpreters.

You can add and remove interpreters and clean up references to interpreters that you uninstalled, but that still appear in the list. In addition, you can set the interpreter to use by default.

## Creating a Virtual Environment

To create a virtual environment (`venv`) when you use the Qt for Python Application wizard templates to create Python projects, select the Create new virtual environment check box on the Define Python Interpreter wizard page. Specify the directory where to create the environment in Path to virtual environment.

## Using Python Interactive Shell

You can write Python code in the Edit mode. Select REPL on the toolbar to start the Python interactive shell in the Terminal pane.

To start the shell and import the current file as a module, select REPL Import File. To also import all functions from the file, select REPL Import *.

Using GitHub Copilot ◦ Editing MIME Types