Handling of flags in PyQt5 / PyQt6

Kovid Goyal kovid at kovidgoyal.net
Tue Mar 16 17:17:20 GMT 2021


On Tue, Mar 16, 2021 at 05:16:01PM +0100, Florian Bruhin wrote:
> Hey again,
> 
> On Tue, Mar 16, 2021 at 04:55:42PM +0100, Florian Bruhin wrote:
> > Or as a more compact overview:
> > 
> > PyQt5: enum only (or unscoped)
> > PyQt6: flags only
> > PySide2: flags only (or unscoped)
> > PySide6: flags only (or unscoped)
> 
> Well, looks like I successfully confused myself with the Alignment vs.
> AlignmentFlag names. Let me try again, please disregard the earlier
> mail.
> 
> 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).

Not only that, it should restore unscoped access as well. It's patently
absurd to have to type a whole extra scope name everywhere when there are
actually very few name collisions. *Every* other Python Qt wrapper
allows unscoped access.


More information about the PyQt mailing list