7

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

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
Theo
  • 1,385
  • 2
  • 10
  • 19
  • 1
    What did you try exactly? – Jablonski Oct 01 '14 at 17:06
  • 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 – Theo Oct 01 '14 at 17:20

2 Answers2

4

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);
mostafaTmj
  • 363
  • 4
  • 12
  • 1
    This only works if you set the parent of the QDialog object; Note that it does not remove the maximize button. (this is a KDE only behavior) – Theo Oct 03 '14 at 00:23
0

From the Qt Documentation:

In Linux with KDE this code make a window without an close and minimize and maximize buttons in title bar.

setWindowFlags( Qt::Dialog | Qt::WindowTitleHint );
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
  • 3
    Two Issues Here: (a) This only works if you set the parent of the QDialog object; (b) This code removes the minimized button, but not the maximize. – Theo Oct 03 '14 at 00:21