Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QDialog - How to remove the minimize button

Qt 4.8 based, application - Issue with QDialog, minimize button

  • Windows and Gnome (linux)

    • The modal dialog appears with the close button on the right top, and the minimize button is nonexistent.
    • The minimize option are grayed out in every dialog.
    • This makes sense, since the QDialog is modal - if you minimize it, the whole application will be blocked.

But here comes the issue:

  • in KDE (linux) the minimize-maximize button appears.

It seems that this is a platform dependent feature -

I am not quite sure on what do do.

Any ideas...? (I tried already with a few windowsFlags but could not find the one set that works.

Tried:

  • setWindowFlags( Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint );
  • Qt::WindowFlags flags = getWindowFlags( ); flags |= Qt::WindowMinimizeButtonHint; setWindowFlags(flags)

--- But the basic question is why the behavior on Windows/GNOME is different from KDE

like image 731
Theo Avatar asked Oct 01 '14 16:10

Theo


People also ask

How do I hide maximize button in Qt?

To turn off the Maximize Button on the default windows, set the max size of your Window on your Ui file. You will notice the Maximize button is greyed out when you run your program.

How do you remove minimize and maximize button in Windows?

To remove the minimize, maximize, and close buttons from your form, open your form in Design View. Under the View menu, select Properties. When the Properties window appears, set the "Control Box" property to "No". Now when the form is opened, the buttons will no longer appear in the top right of the form.

What is the minimize button called?

Alternatively called a collapse box, minimize box, and minimize button, minimize is an action in GUI operating systems to hide a window, but keep the program running in the background.


1 Answers

if you want the MainWindow don't have any buttons on top use this in constructor of MainWindow:

this->setWindowFlags(Qt::SubWindow);

and if you want to remove just the minimize button use this:

this->setWindowFlags(Qt::Dialog);
like image 184
mostafaTmj Avatar answered Oct 03 '22 06:10

mostafaTmj