Getting there, about 90% of the code is migrated for both PyQt6 & PySide6. Then I have a list of changes to make to the book/conditional sections for the new libraries + we’re good to go for a initial release. The v6 versions will be available to anyone who’s bought an earlier edition.
All the code for the different versions is auto-generated from the PyQt5 source. PyQt5 to PySide2 requires replacing the imports and signal/slot names + some manual handwritten replacements for the UI loader. The same process has been done for v6 and that’s given me some insight into where the incompatibilities are.
Some first thoughts from the migration –
- PyQt6 is less directly source-compatible with PyQt6 than PySide6. In PyQt6 the namespaces have been moved under Python Enums so e.g.
Qt.DisplayRole is now under
Qt.ItemDataRole.DisplayRole. The same structure exists now in PySide6, but the old locations are retained, so it’s backwards compatible
Qt.ItemDataRole.BackgroundRole == Qt.BackgroundRole. I’m 50/50 on whether to use the new style in the PySide6 book – thoughts?
- (PyQt6 & PySIde6)
QAction is now in
QtWidgets. This always caught me out (since it’s not a widget) so I think it’s a good change. But it’s hard to auto-migrate.
- (PyQt6 & PySIde6) Retrieving a pixmap now seems to return a copy: if you get a labels pixmap and draw on it, it doesn’t affect the widget. Required a rewrite of the custom widget code. May be missing something here, early days.
QMouseEvent now doesn’t have
.y() which is odd. You need to get a position via
The matplotlib examples won’t work until Qt6 is supported there and there is (as yet) no support for packaging PyQt6/PySide6 in PyInstaller or fbs. I’ll remove this part of the book until it becomes available.
Should be out, at least in an “early access” form, by next week.