Skip to content

PyQt6 migration: scoped enum errors on startup #415

@zarcoder

Description

@zarcoder

Description

When migrating Friture from PyQt5 to PyQt6, several AttributeError exceptions occur on startup due to PyQt6's scoped enums. In PyQt6, all Qt enums must be accessed through their full scope (e.g. QIcon.Mode.Normal instead of QIcon.Normal).

Environment

  • Platform: macOS (Darwin)
  • Python: 3.14.3
  • PyQt6: 6.11.0

Errors encountered

1. qmlRegisterSingletonType argument order changed

TypeError: arguments did not match any overloaded call:
  qmlRegisterSingletonType(a0: type, uri: str, major: int, minor: int,
    factory: Callable[[QQmlEngine, QJSEngine], Any], name: str = None):
    argument 5 has unexpected type 'str'

Fix: swap name and factory arguments.

2. Qt.RichTextQt.TextFormat.RichText

AttributeError: type object 'Qt' has no attribute 'RichText'

3. QIcon.Normal / QIcon.Off

AttributeError: type object 'QIcon' has no attribute 'Normal'

Fix: QIcon.Mode.Normal, QIcon.State.Off

4. QPalette.Window / QPalette.Base

AttributeError: type object 'QPalette' has no attribute 'Window'

Fix: QPalette.ColorRole.Window, QPalette.ColorRole.Base

5. QSizePolicy.Minimum / QSizePolicy.Expanding

Fix: QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding

6. QDialogButtonBox.setOrientation() removed in Qt6

Fix: Remove the call (orientation is automatic).

7. QSGGeometry.DrawTrianglesQSGGeometry.DrawingMode.DrawTriangles

8. QSGNode.OwnsGeometryQSGNode.Flag.OwnsGeometry

9. QSGNode.DirtyGeometryQSGNode.DirtyStateBit.DirtyGeometry

10. QQuickItem.ItemHasContentsQQuickItem.Flag.ItemHasContents

11. QML imports: version numbers must be removed

All import QtQuick 2.15 style imports must become import QtQuick.

Log file

$(cat /Users/zarcoder/Library/Logs/Friture/friture.log.txt | tail -60)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions