Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. mainWindow disable maximize button
Forum Updated to NodeBB v4.3 + New Features

mainWindow disable maximize button

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmainwindowmaximize
3 Posts 2 Posters 5.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Gianluca86G Offline
    Gianluca86G Offline
    Gianluca86
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • bhavin03B Offline
      bhavin03B Offline
      bhavin03
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      1
      • Gianluca86G Offline
        Gianluca86G Offline
        Gianluca86
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved