1

I've tried everything I can think of, but no matter what I do, I get this error whenever I try to set the window's attribute "FramelessWindowHint." First, here is the code:

import sys
from PyQt6.QtWidgets import QApplication, QWidget
from PyQt6.QtCore import Qt

class MainApp(QWidget):
    def __init__(self):
        super().__init__()
        
        self.setWindowFlags(Qt.FramelessWindowHint)

app = QApplication(sys.argv)
window = MainApp()
window.show()
sys.exit(app.exec())

This is my code. When I run it without the line self.setWindowFlags(Qt.FramelessWindowHint), it works fine, and I can add other elements, I just stripped it down for the question. The "ID" for FramelessWindowHint, at least in PyQt5, is 2048. If I try this using PyQt5, it works fine, but when I try replacing the from PyQt6.QtCore import Qt with PyQt5, it throws an error:

TypeError: setWindowFlags(self, Qt.WindowFlags): argument 1 has unexpected type 'WindowType'

I have searched everywhere I can think of, and nobody else has this problem as far as I can find. I looked in https://www.riverbankcomputing.com/static/Docs/PyQt6/api/qtcore/qt.html but it doesn't say anything about this, it shows FramelessWindowHint normally.

If anyone else has had this problem or knows the solution, please let me know. I'll try to reply as soon as possible, TIA!

Fun840
  • 107
  • 1
  • 7
  • 2
    PyQt6 has changed the way flags and enums are dealt with, now they are only accessible through the flag names. Try with `Qt.WindowFlags.FramelessWindowHint`. – musicamante Apr 05 '21 at 22:15
  • @musicamante Wow, that was a lot simpler than I thought it would be, thanks so much! Would you mind posting that as an answer so I can mark it as one? – Fun840 Apr 05 '21 at 22:18
  • 2
    I don't think there would be need for that, as the question already has a very similar duplicate [How to check MouseButtonPress event in PyQt6?](https://stackoverflow.com/questions/66235661/how-to-check-mousebuttonpress-event-in-pyqt6) – musicamante Apr 05 '21 at 22:24
  • 1
    Note: It's actually `Qt.WindowType.FramelessWindowHint` – Iosvany Dalmau Nov 13 '21 at 10:11

0 Answers0