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.RichText → Qt.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.DrawTriangles → QSGGeometry.DrawingMode.DrawTriangles
8. QSGNode.OwnsGeometry → QSGNode.Flag.OwnsGeometry
9. QSGNode.DirtyGeometry → QSGNode.DirtyStateBit.DirtyGeometry
10. QQuickItem.ItemHasContents → QQuickItem.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)
Description
When migrating Friture from PyQt5 to PyQt6, several
AttributeErrorexceptions 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.Normalinstead ofQIcon.Normal).Environment
Errors encountered
1.
qmlRegisterSingletonTypeargument order changedFix: swap
nameandfactoryarguments.2.
Qt.RichText→Qt.TextFormat.RichText3.
QIcon.Normal/QIcon.OffFix:
QIcon.Mode.Normal,QIcon.State.Off4.
QPalette.Window/QPalette.BaseFix:
QPalette.ColorRole.Window,QPalette.ColorRole.Base5.
QSizePolicy.Minimum/QSizePolicy.ExpandingFix:
QSizePolicy.Policy.Minimum,QSizePolicy.Policy.Expanding6.
QDialogButtonBox.setOrientation()removed in Qt6Fix: Remove the call (orientation is automatic).
7.
QSGGeometry.DrawTriangles→QSGGeometry.DrawingMode.DrawTriangles8.
QSGNode.OwnsGeometry→QSGNode.Flag.OwnsGeometry9.
QSGNode.DirtyGeometry→QSGNode.DirtyStateBit.DirtyGeometry10.
QQuickItem.ItemHasContents→QQuickItem.Flag.ItemHasContents11. QML imports: version numbers must be removed
All
import QtQuick 2.15style imports must becomeimport QtQuick.Log file