How can I remove the minimize button from QMainWindow in Python?
I'm using Python 3.4 with PySide. thanks
You need to utilize setWindowFlags
do prevent the minimize and maximize button from appearing. You'll have to set the appropriate flags as well.
In this case, you need to enable CustomizeWindowHint
and then disable both WindowMinimizeButtonHint
and WindowMaximizeButtonHint
(alternatively, you could just disable WindowMinMaxButtonsHint
, which handles the previous two flags).
A very simple program demonstrating how this works:
import sys
from PySide import QtGui
from PySide import QtCore
def main():
app = QtGui.QApplication(sys.argv)
w = QtGui.QWidget()
w.resize(250, 150)
w.move(300, 300)
w.setWindowTitle('Simple')
w.setWindowFlags(w.windowFlags() & QtCore.Qt.CustomizeWindowHint)
w.setWindowFlags(w.windowFlags() & ~QtCore.Qt.WindowMinMaxButtonsHint)
w.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Outputs: