Remove/Disable Close Button in PyQt5
The answer is the same as the answer in the question you linked to. Only a slight change is necessary.
self.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False)
The CustomizeWindowHint
flag needs to be set first before the WindowCloseButtonHint
flag can be changed.
See https://stackoverflow.com/a/27496734