F
F
frontjss2020-01-30 16:08:27
Python
frontjss, 2020-01-30 16:08:27

How to remove the entire header of a QWidget in PYQT5?

How can I remove the minimize close buttons and the whole header from the program window?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bbkmzzzz, 2020-01-30
@bbkmzzzz

Set window flags

import sys

from PyQt5.QtCore import QSize, Qt
from PyQt5.QtWidgets import QApplication, QMainWindow


class Main(QMainWindow):
    def __init__(self):
        super(Main, self).__init__()
        self.resize(QSize(800, 600))
        self.setWindowFlags(Qt.FramelessWindowHint)  # окно без рамки

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Main()
    ex.show()
    sys.exit(app.exec_())

When setWindowFlags is called, the current flags are overwritten, if more than one is needed, use |
The window manager has the right to ignore these flags and interpret them at will, it must be taken into account.
Here (Qt Docks) you can read (where there is Hint in the name)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question