Handling of flags in PyQt5 / PyQt6

Dmitry Shachnev mitya57 at ubuntu.com
Tue Mar 16 17:34:01 GMT 2021


Hi Florian!

On Tue, Mar 16, 2021 at 05:16:01PM +0100, Florian Bruhin wrote:
> PySide2 and PySide6 both allow access via the *enum* name only. To make
> it clearer, let me try again with Qt.Orientation (enum) vs.
> Qt.Orientations (flag):
>
> PyQt5:   Qt.Horizontal (unscoped) or Qt.Orientation.Horizontal (enum)
> PyQt6:   Qt.Orientations.Horizontal (flag)
> PySide2: Qt.Horizontal (unscoped) or Qt.Orientation.Horizontal (enum)
> PySide6: Qt.Horizontal (unscoped) or Qt.Orientation.Horizontal (enum)
>
> So PyQt6 seems like the "oddball" here. I'm fine with using scoped
> values everywhere, but I think PyQt6 should support accessing flag
> values via the enum type, so that it's possible to write code which
> works with PyQt5 and PyQt6 (or PyQt6 and PySide6).

Thank you for bringing this up. I encountered the same problems when trying
to port my code from PyQt5 to PyQt6. See the commit messages for the changes
I had to make:

https://github.com/retext-project/retext/commits/wip/qt6

Dropping support for unscoped enums is fine for me, but having a way to
write code that will work with both PyQt5 and PyQt6 would be nice.

--
Dmitry Shachnev


More information about the PyQt mailing list