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

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.
  • G Offline
    G Offline
    Gianluca86
    wrote on 26 Jul 2016, 13:18 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
    • B Offline
      B Offline
      bhavin03
      wrote on 26 Jul 2016, 14:05 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
      • G Offline
        G Offline
        Gianluca86
        wrote on 26 Jul 2016, 14:13 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

        1/3

        26 Jul 2016, 13:18

        • Login

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