Darkos Darkos - 23 days ago 10
Python Question

pyqt - Frameless widget weird titlebar appears

I noticed a weird behavior when running a frameless widget in PyQt.
If I minimize it in taskbar multiple times, a Windows XP title bar appears in the top left corner during a few milliseconds and then disappears.

Here is a simple code to reproduce the problem :

import sys

from PyQt5 import QtCore, QtWidgets


if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
ui = QtWidgets.QWidget()
ui.setWindowFlags(ui.windowFlags() | QtCore.Qt.FramelessWindowHint)
ui.show()
sys.exit(app.exec_())


The behavior is described in this video

My setup is Windows 7 (x64), Python 3.5 and PyQt5.7
(FYI, the problem was also present in PyQt5.6)

Can anyone explain this behavior and give a solution ?

Answer

I reported the issue to Qt and it seems to be a general Windows bug :

Sergio Martins added a comment

I can reproduce this problem with a pure Windows example, (passing WS_VISIBLE | WS_POPUP | WS_SYSMENU | WS_MINIMIZEBOX to CreateWindowEx()). Doesn't seem fixable, other than removing the minimize button capability.