Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

mainWindow disable maximize button



  • Hi,
    I'm trying to disable the maximize button in mainWindow.
    I use this line 2:

    // main.cpp
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
        w.showMaximized();
    }
    

    In windows it works well (qt 5.7.0 and win 10) while on Ubuntu 14.04 32bit (qt 5.5.1) the maximize button remains active.
    is a bug or something wrong with my code?
    Thank you



  • Hallo,
    I also didnt found any direct way.. but this lines below in constructor will do the job..!

    ui->setupUi(this); // default UI initializer
    this->setFixedSize(this->width(),this->height());
    

    regards



  • I need to be as big as the screen.
    Before I used this code to display it as big as the screen

    int Height = 0;
    int Width = 0;
    foreach (QScreen *screen, QGuiApplication::screens()) {
         if(QGuiApplication::primaryScreen()->name() == screen->name())
         {
            QRect rec = screen->availableGeometry();
            Height = rec.height();
            Width = rec.width();
         }
    }
    
    w.setFixedSize(Width,Height);
    

    Unfortunately, I do not know why, the height is still longer than the screen. This is why I decided to use showMaximized (), unfortunately this does not seem to go well for both systems.


Log in to reply