I have installed qt (the open source version) and would like to code with python 3 in it. I write a code, however, I cannot compile it because the "build" tab and button are not active (they are grey). What can the problem be, and what should I do?
-
Qt Creator does not allow to launch an application written in python, so open a console/CMD and execute it with python your_script.py – eyllanesc Jul 11 '19 at 08:30
1 Answers
Short answer: Qt Creator is not designed for working with Python
Longer answer: The purpose of Qt Creator is really for using Qt in C++. Many of the features of the IDE revolve around that and will be unavailable if you aren't working with a Qt C++ project. This is why a "Build" menu exists: the commands there are for running the Qt and C++ compilers. Note that Python (a scripting language) does not require compilation, so it wouldn't make sense to attempt to compile your code anyway.
It might be that you're using Qt Creator because you're making use of one or more of the Qt modules that exist in Python (e.g. PyQt, PySide). These modules have been created as "bindings" to the Qt application framework allowing you to (for example) create Qt-style GUI applications in Python, but they have no requirement for you to use the Qt Creator IDE.
Alternatives: While Qt Creator is fine as a general code editor, in general I would recommend using another IDE for writing Python, such as Visual Studio Code (more flexible) or PyCharm (specifically for Python). If you want to stick with Qt Creator you can configure it to allow you to run your Python like this.
Finally, it's worth pointing out that it's possible to use the Qt Creator UI designer and then export the created files into a Python Qt application. See this question and its responses for more info.

- 1,548
- 1
- 10
- 14
-
-
My purpose of using Qt is to write apps using pyqt. Could you please tell me how I can do that in Qt? – Alex L Jul 13 '19 at 00:23
-
You don't need to use qtcreator. Just use a text editor to write your code and then run it in the terminal (e.g. `python3 my_program.py`) – Benp44 Jul 15 '19 at 16:09