PyQt6: Qt module enums raise AttributeError [duplicate]
Asked Answered
C

1

6

I need to translate the following code from PyQt5 (It works there) to PyQt6:

self.setWindowFlags(Qt.FramelessWindowHint)

This is the error:

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

I've already tried this:

self.setWindowFlags(Qt.WindowFlags.FramelessWindowHint)

It says:

AttributeError: type object 'Qt' has no attribute 'WindowFlags'
Crete answered 28/10, 2021 at 1:45 Comment(3)
Please put all your codeRackrent
Perhaps a little more code would help.Flaring
See the PyQt5 Docs: Things to be Aware of - Enums. In PyQt5, enum members were available as both attributes of the class/module (e.g. Qt.FramelessWindowHint) and as attributes of the enum itself (e.g. Qt.WindowType.FramelessWindowHint); but in PyQt6, only the latter is supported. It should also be noted that PyQt6 always uses the name of the enum type rather than the flags type (see e.g. Qt::WindowFlags).Conscionable
T
12

That flag now lives here:

QtCore.Qt.WindowType.FramelessWindowHint
Torres answered 28/10, 2021 at 1:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.