QDialog - How to remove a minimize button

Qt 4.8 based, application - QDialog issue, decrease button

  • Windows and Gnome (linux)

    • A modal dialog box appears with a close button at the top right, and the minimize button is nonexistent .
    • In each dialog box, the Reduce option is grayed out.
    • This makes sense since the QDialog is modal - if you minify it, the entire application will be blocked.

But here comes the problem:

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

It seems to be platform dependent -

I'm not really sure what to do.

Any ideas ...? (I've tried with several windowsFlags already, but couldn't find one that works.

Tried:

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

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

+3


source to share


2 answers


if you want MainWindow to have no buttons, use this in the MainWindow constructor:

this->setWindowFlags(Qt::SubWindow);

      



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

this->setWindowFlags(Qt::Dialog);

      

+1


source


From Qt Documentation :



On Linux with KDE, this code makes a window without closing and minimizes and maximizes buttons in the title bar.

setWindowFlags( Qt::Dialog | Qt::WindowTitleHint );

      

0


source







All Articles