Qt 5.14 Release!! I'm sorry for the story that has nothing to do with the theme suddenly. Everyone, Qt 5.14 has been released! !! When I tried to install Qt for the first time in a while, I noticed (actually, I noticed when I was with hermit ...). I thought about installing 5.14 immediately, but this time the purpose was not to use new features, but considering compatibility with binding tools etc., I thought that the latest LTS 5.12.6 was safe. When I have time, I'll try 5.14 as well.
This is my 7th post, HW developer ynuma. I will briefly write about the latest situation.
It's early, and my daughter is almost 3 years old. The other day, I took a picture of Shichigosan. Holidays are a daughter-centered life.
There is no big change in the work situation, but I use Python to make evaluations that incorporate machine learning. I rarely use Qt, but I am motivated to create applications as a hobby, so I would like to continue learning.
This is the main subject, but this time the theme is about PyQt. Do you all know?
Initially, I was planning to focus on work-related machine learning, but unfortunately I couldn't do it this time because I found out that Qt itself does not have a function to support machine learning (if I made a mistake, I couldn't do it. Please teach). If you're doing machine learning, I think the trend is to use Python. Since Python has a relatively long history, I think that there are abundant libraries such as graphing, but I thought that it would be convenient if I could use the functions of Qt that I have some knowledge from Python.
By Kazuo Asano "Let's make a GUI with Python" I will refer to it for a considerable part. 12/12 Article posted by spiralgear Introduction of Qt-related books that could be supplemented within the range of personal observation But it is introduced. There are plenty of diagrams and explanations, and even beginners can easily understand it, so I recommend it! !! I think it's also attractive to have a lot of examples of QtQuick.
First of all, since it is an introductory edition, I am targeting those who know Qt to some extent but have never used PyQt. Or if you're using Python and want to take advantage of Qt's rich features, you'll find it helpful.
Qt's Python binding was developed by Riverbank Computing in the United Kingdom. Binding means connecting. In short, it's what connects Python and Qt. More specifically, I think it's meant to allow you to call Qt from Python.
History I didn't know exactly when it was developed, but it seems to have existed around 2007. PySide, which was developed by Nokia (now The Qt Company), is said to be of the same type, but it seems that it was developed as an alternative due to a failure to reach a license agreement with PyQt's Riverbank Computing.
PyQt is the GPL. For reference, PySide is the LGPL. If you prioritize corporate profits, you may want to use PySide, but PyQt seems to be more convenient. Which one to adopt as a company is a difficult place.
Install Below is a brief summary of the steps to get PyQt working.
Anaconda seems to provide the following functions. ・ Multiple Python virtual environments can be created ・ Multiple Python versions can be used properly -It is possible to use the Python interpreter properly for each environment. ・ Package management system conda can be used
There is a lot of information on the Web about the procedure details, so I will omit it.
Qt Install As you all know, it's easy to download and run the Qt online Installer from the site below. https://www.qt.io/download-open-source
Last login: Fri Dec 13 03:13:56 on ttys000
(base) numac:~ ynumajir$ /Users/ynumajir/.anaconda/navigator/a.tool ; exit;
(Python3_7) bash-3.2$ pip install PyQt5
Collecting PyQt5
Downloading https://files.pythonhosted.org/packages/93/5b/2ba062584e8b407b443b7ac7b6687e157d22b0f875cfd1dbe5baf82f6177/PyQt5-5.13.2-5.13.2-cp35.cp36.cp37.cp38-abi3-macosx_10_6_intel.whl (39.8MB)
|████████████████████████████████| 39.8MB 23.1MB/s
Collecting PyQt5_sip<13,>=4.19.19
Downloading https://files.pythonhosted.org/packages/ca/77/ac0e8908be37523f0d93b8002641d11cfbc231c3e9dbaa4835f8073b397d/PyQt5_sip-12.7.0-cp37-cp37m-macosx_10_9_x86_64.whl (62kB)
|████████████████████████████████| 71kB 8.5MB/s
Installing collected packages: PyQt5-sip, PyQt5
Successfully installed PyQt5-5.13.2 PyQt5-sip-12.7.0
(Python3_7) bash-3.2$ pip list
Package Version
---------- -------------------
certifi 2019.11.28
pip 19.3.1
PyQt5 5.13.2
PyQt5-sip 12.7.0
setuptools 42.0.2.post20191201
wheel 0.33.6
(Python3_7) bash-3.2$
Below is the python code that displays a simple MainWindow.
QMainWindow.py
# - * - coding: utf8 - * -
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.title = 'PyQt test(QMainWindow)'
self.width = 400
self.height = 200
self.setWindowTitle(self.title)
self.setGeometry(0, 0, self.width, self.height)
label = QLabel('This is PyQt test.', self)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
sys.exit(app.exec_())
Below are the execution results.
$ python QMainWindow.py
Now you can use the Qt library from Python.
This time, I've summarized the steps up to the point where you can make a simple call to Qt using PyQt. Since the Anaconda and python environments were originally set up on the PC used, it was relatively easy to start up. As a result, I think it has become possible to display machine learning results on the Qt GUI. Next time, I would like to find out if I can make a 3D graph with PyQt as easily as possible.
Recommended Posts