Python / PyQt5: resize button

Solved
Medestrac -  
 Medestrac -

Hello,

I created a window in Qt Designer with different widgets that resize according to the window.

When I run the code, the window appears correctly, and I can resize it manually, but the "Maximize" button in the title bar appears grayed out. The "Minimize" and "Close" buttons work fine, but I cannot click on the "Maximize" button.

Do I need to enable it in some way?

2 answers

Medestrac
 

I found: there was a max value set for the window, which disables the possibility of maximizing it. I reset the values to default and it works.

1
mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   7 940
 

Hello,

Attention, purists insist, it's Qt and not QT, because the goal is for it to be pronounced "cute" :-)

Have you tried this?

import sys from PyQt5.QtWidgets import QDialog, QApplication from PyQt5.QtCore import Qt class MyForm(QDialog): def __init__(self): super().__init__() self.setWindowFlag(Qt.WindowMinimizeButtonHint, True) self.setWindowFlag(Qt.WindowMaximizeButtonHint, True) self.show() if __name__=="__main__": app = QApplication(sys.argv) w = MyForm() w.show() sys.exit(app.exec_())

Good luck

0
Medestrac
 

Hello,

I tried but it doesn't change anything. I have a QMainWindow and not a QDialog.

class MyWindow(QMainWindow): def __init__(self): super(MyWindow, self).__init__() self.my_ui = Ui_MainWindow() self.my_ui.setupUi(self) self.setWindowFlag(Qt.WindowMinimizeButtonHint, True) self.setWindowFlag(Qt.WindowMaximizeButtonHint, True) if __name__ == '__main__': app = QApplication(sys.argv) win = MyWindow() win.show() sys.exit(app.exec()) 
0