QT python GUIs : how to view code in qt designer - python

I want to learn to use qt designer and i want to know what to install, because I've had some issues with python versions and distributions. This is my first time doing this I know basically nothing about python or QT. I appreciate your help

Qt Designer is just a quick way to visually define the GUI. You can then load the .ui files created there in you python application or convert them to python code: Convert pyQt UI to python. But I would rather recommend you to write the code from scratch by yourself. This way you can better understand how the things are actually work.
Qt is a C++ framework, if you want to use it with python you have to pick a python binding first. You basically have two choices here: PyQt and PySide. PyQt is proprietary software developed by Riverbank Computing Limited. PySide is open source software and nowadays the official Qt binding for python.
Similar to python with its major versions 2 and 3, Qt has two major versions Qt4 and Qt5 that are widely used. PyQt4 and PySide are Qt4 bindings, PyQt5 and PySide2 are Qt5 bindings.
So if you have no specific requirements regarding the version you should use, just install the latest version of Python, install PySide2 using pip and enjoy studying GUI programming with Python and Qt!

Related

Why is the "build" tab inactive for me in qt?

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?
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.

Python + QT or GTK + Material design. Is it possible?

As I can see, QT has an official material design theme: https://doc.qt.io/qt-5.10/qtquickcontrols2-material.html
I've been searching for Python QT bidings, and it looks like the most famous are PySide, PySide2 (in development) and PyQt4 or 5
I even found a repository which creates a python material design support but it's ugly and unmaintaned: https://github.com/ethanhs/material
I've read that it's possible to convert QT Creator ui files to python code. Is it possible t use Qt Creator to create a material design interface and compile to python code OR save as XML and import using a python qt library?
I've found some material design themes for GTK, but they are installabe themes for GNOME, not something that would be default in the application look. So GTK is less desirable because I'm constrained to GNOME guidelines.
Do you have another possible solution in mind even if it doesn't involve QT or GTK? Note that, however, video displaying is necessary.

Can I use PyQt for both C++ and Python?

I'd like to learn Qt both on Python and C++. I am on Windows.
Is instaling PyQT5 with pip3 install pyqt5 enough for C++ development or do I still have to install both Qt and PyQt?
How do I do the second option?
For C++ development you're going to need a C++ compiler. On Windows Qt supports both the Mingw and Visual Studio toolchains. From there, I don't believe pyqt includes the header files you're going to need for C++ development and I cannot say for certain what toolchain it was compiled with.
Your best bet is either install the official Qt binaries for your compiler, or build the binaries from source (the later will take some time and effort.)
If you want to mix both C++ and Python in a single Qt project, check out SIP bindings.
Another thing to keep in mind is that pyqt5 comes with the LGPL licensed version of Qt by default. This may or may not be appropriate for your project(s), but StackOverflow isn't intended to discuss licensing issues.
PyQt5 is for developing with Python.
If you want to code in C++ the best you do is to download Qt5 and code inside QtCreator.
Here is a link for Qt5 Opensource

Is there a way to create a GUI in python, like in VisualStudio or AndroidStudio?

I wanted to know if there is a program like VisualStudio or AndroidStudio for python.
I mean, a program that can create a visual GUI and I just need to program the buttons I had planed in the GUI I made.
PySide or PyQT require QT which allows you to use Qt Creator.
http://en.wikipedia.org/wiki/Qt_Creator
It's a bit of a workaround but the libraries come with a script (e.g. pyside-uic for pyside) which can convert qt creator files into python classes. You'll also need to setup another class which reads and creates the gui's, but this is all documented for pyside online here:
http://qt-project.org/wiki/QtCreator_and_PySide
A quick web search brings up a few possibilities:
http://wiki.wxpython.org/wxPythonPit%20Apps#Programming:_GUI_tools
http://wxglade.sourceforge.net/
https://wiki.python.org/moin/GuiProgramming
https://wiki.python.org/moin/GUI%20Programming%20in%20Python
Like #kartikg3 asked, what platform are you working/deploying on?

Why must I use Qt Designer 2.7 with Python 2.7?

Why can't I use other Qt series with different Python releases?
You can. If you have a specific version of Qt you would like to use, you can either download a matching PyQt version from Riverbank's download site or you can compile your own version of PyQt. I've had to build them from scratch a few times when the provided binaries didn't match the Qt/Python versions I wanted to use. It's a bit of a hassle to compile but it's definitely possible.
Also, note that the up-and-coming PySide library is an alternative Qt binding for Python that looks like it has a good chance of supplanting PyQt (due to looser licensing constraints).
Generally speaking, Qt Designer is an optional and independent component from PyQt. You can use it to create your .ui files but after that, it's up to the developer to determine how to use them... either generate Python code from them with pyuic4 or load them dynamically. As long as the format of the resulting .ui files are compatible with your version of PyQt, it shouldn't matter which Designer version you're using (though I would strongly recommend you use the version matching the Qt version PyQt is linked against).

Categories

Resources