How to disable maximize button in QT?

14,863

Solution 1

To turn off the Maximize Button on the default windows, set the max size of your Window on your Ui file.

For example:

enter image description here

You will notice the Maximize button is greyed out when you run your program.

If you want your window to ever only be the one size and give the user no control to change it, set the Geometry and the Minimum size to these same values.

Solution 2

SetWindowsFlags(); didn't work for me on Ubuntu 16.04,but under ui->setupUi(this) I added this line:

setFixedSize(width(), height());

and it works fine.

Solution 3

setWindowFlags(Qt::Drawer);

cool :)

Share:
14,863

Related videos on Youtube

Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I want to disable maximize button in the Qt

    I tried

    setWindowFlags( (windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowMaximizeButtonHint); 
    
    • Alex F
      Alex F over 5 years
      setWindowFlags(windowFlags() &(~Qt::WindowMaximizeButtonHint));
  • DaniV
    DaniV over 3 years
    Great answer, best regards!!