Qt hide minimize, maximize and close buttons

45,884

Solution 1

Set this window flags Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint

Note, that on some platforms it behaves in different way. For example on Mac OS X it Disables, (not hides) close/minimize/maximize buttons

Solution 2

If you are using Qt qml then, to remove minimize, maximize and close button, set the frameless window flag in the window function in your main.qml file, like below:

flags: Qt.FramelessWindowHint

Solution 3

Just watch how Window Flags Example works!

Solution 4

This can be achived by using an eventFilter on the QEvent::Close event from your MainWindow

bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
    if (event->type() == QEvent::Close) {
        event->ignore();
        doWhateverYouNeedToDoBeforeClosingTheApplication();
        return true;
    }
    return QMainWindow::eventFilter(obj, event);
}
void MainWindow::doWhateverYouNeedToDoBeforeClosingTheApplication() {
    // Do here what ever you need to do
    // ...
    // ...
    // and finally quit
    qApp->quit();
}

Solution 5

For the close button, you can override the closeEvent() of QmainWindow

class MainWindow(QMainWindow):    
    def closeEvent(self, event):
        event.ignore()
        return
Share:
45,884

Related videos on Youtube

ufukgun
Author by

ufukgun

:) c++ java openGL delta3D osg glsl qt equalizer openAL ...

Updated on July 09, 2022

Comments

  • ufukgun
    ufukgun 6 months

    Do you know how to hide minimize, maximize and close buttons of title bar in Qt. I especially need to hide it on QMainWindow.

    • static_rtti
      static_rtti over 12 years
      Could you mention why you need to do that?
  • ufukgun
    ufukgun over 12 years
    thank u mosg. actually my main problem is hiding close button on mainWindow.

Related