pythonuser-interfacepyqt5qmainwindowframeless

How to undo Qt.FramelessWindowHint from a QMainWindow?


The application that I am trying to make needs a frameless window in the first stage, then I need to set it framed back.

so I need to inactivate the following line --> self.setWindowFlag(Qt.FramelessWindowHint)

I searched a lot but I had no satisfying answer. Can you please help me, guys?

Thanks in advance.


Solution

  • Hope you are almost there, inside your mainwindow init, First you have to add this line while initialization,

    Flags = QtCore.Qt.QWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTop)
    self.setWindowFlags(Flags)
    
    

    Later you can set None to windowflags. Hope this helps.