Qt.py
Qt.py copied to clipboard
Conversion guide
Converting a project initially developed wih PyQt4, PyQt5 or PySide should be relatively straightforward and similar across projects. Let's collect our thoughts on some of the things to consider when heading down this route.
#### From PySide2
Qt.py conforms to the interface of PySide2, so if your code is already written for that you should only ever need to:
- Search-and-replace
PySide2
withQt
and you're done.
From PySide
This should be relatively straightforward as well.
- Replace references to
QtGui
withQtWidgets
apart from a few exceptions.
From PyQt5
Here I'd imagine:
- Look into the different names for signals and properties, e.g.
pyqtSignal
From PyQt4
Prepend this to the steps outlined for PyQt5
- Convert code via pyqt4topyqt5
Finally, look towards CAVEATS.md
for details and workarounds.
### What else?
What's missing? Let's fill in the blanks.
Hm. Wasn't something moved to/from QtCore in Qt5... I can't remember right now.
Some additional material for reference.
- https://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5
Maybe that's the way to go? To populate a list of links to existing links? The Qt Company is likely on the same mission for their own sake.
This is a huge issue.
Let's make it less frightening, how about an example of something you currently have or have mocked up specifically for this guide of a typical project importing PySide
and using QWidget
and friends from QtGui
along with qApp
and how you can transition these to Qt.py and enter the land of Qt 5?
Just enough to give the reader the most basic idea of the work that lies ahead.
# Example
import sys
from PySide import QtGui
self = sys.modules[__name__]
self.active_window = None
class Window(QtGui.QDialog):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
def show():
try:
self.active_window.deleteLater()
except:
pass
window = Window()
window.show()
self.active_window = window
How about extending lib2to3 in python standard library ( add some custom fixers) to make the conversion ?
Sounds interesting, you're welcome to give it a shot.