Developing Qt for Python Applications
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
- Launching the Debugger
For more information about developing with Qt for Python, including limitations, see Qt for Python.
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.
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.
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.
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 *.
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.