Description
In #1864 @DylanC and I were discussing the Timeline implementation and the possible benefits of QML / QT Quick when compared to the current Angular JS.
I realized that there's another, potentially related implementation question looming.
Now that there's an official Qt for Python, based on the old PySide project which the Qt team decided to adopt and support, should OpenShot-qt be written in PySide2 instead of PyQt? And, how much would be involved in porting it over?
On the face of it, there's very little difference between the two. The top of one of their example Python source files looks like this:
from PySide2 import QtCore
from PySide2.QtCore import Qt, QUrl
from PySide2.QtGui import QCloseEvent, QKeySequence, QIcon
from PySide2.QtWidgets import (qApp, QAction, QApplication, QDesktopWidget,
QDockWidget, QLabel, QLineEdit, QMainWindow, QMenu, QMenuBar, QPushButton,
QStatusBar, QToolBar)
from PySide2.QtWebEngineWidgets import (QWebEngineDownloadItem, QWebEnginePage,
QWebEngineView)
Which should seem pretty familiar, compared to our src/windows/views/timeline_webview.py
:
from PyQt5.QtCore import QFileInfo, pyqtSlot, QUrl, Qt, QCoreApplication, QTimer
from PyQt5.QtGui import QCursor, QKeySequence
from PyQt5.QtWebKitWidgets import QWebView
from PyQt5.QtWidgets import QMenu
There do appear to be some other differences, though mostly minor.
- PySide2's signal decorator is
@Signal
, not@pyqtSignal
. - PySide2 allows Properties to be declared on Qt objects explicitly, specifying type as well as setter and getter functions. The Property then acts as both a Python property and a Qt property. In PyQt it seems like that's either automatically true for all Python properties, or not supported.
- If integrating with QML, a Property needs to be NOTIFYable. They give this example of how that works. I'm not sure what PyQt's situation is with that, though I know they also support QML integration.
- PySide2 loads UI definitions using
QUiLoader
, via itsload()
method, which takes an already-openedQFile
object. There's noPyQt5.uic
, which takes a pathname. That apparently caused some problems when OpenShot is in its frozen state, with the code having to retry the load a few times to findmain_window.ui
. (Seesrc/classes/ui_util.py
at theload_ui()
function). So, it's possible PySide2 would solve that for us.
Unfortunately, the Qt Wiki document Differences between PySide and PyQt is over three years old and covers only PySide (not PySide2) vs. PyQt4. And while someone did a comparison of PySide2 vs. PyQt5, with a focus on what PySide2 lacked, that was almost 2 years ago.
While a similar comparison has been periodically posted to the Qt Wiki, updated as recently as a couple of months ago (Qt 5.11), whoever ran the most recent comparison didn't have PyQt5 installed, so there's no info on what PyQt5 has that PySide still lacks. In general, though, most of what's missing appears to be either:
- very new;
- very, very obscure; or
- relegated to a few classes that have major holes, like QtDataVisualization and QtCharts (neither of which exists in PyQt5, though they do offer a separate PyQtChart implementation of QtCharts).
There are some more classes that PySide2 provides which PyQt5 does not, though again we're unlikely to touch those: things like Qt3D{Core,Render,Input,Logic,Animation,Extras} (again, there's a separate PyQt3D for those), or QtConcurrent.
As of the most recent report, there are 219 Qt types missing in PySide2. Which may sound like a lot, as of the previous report (vs. Qt 5.9) there were 163 types missing, and only 41 of those present in PyQt5. So, like I said: Mostly either very new, or very obscure.