Results 1 to 18 of 18

Thread: Disabling the Maximize button in QMainWindow ?

  1. #1
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Disabling the Maximize button in QMainWindow ?

    Hi Guys

    How do we diable the Maximize Button in QMainWindow,

    I am using KDE, and the I tried Playing the WindowFlags example. But to No avail.

    I also tried doing this
    Qt Code:
    1. #include <QApplication>
    2. #include <QMainWindow>
    3.  
    4. int main(int argc, char *argv[]) {
    5.  
    6. QApplication app( argc, argv );
    7.  
    8. QMainWindow win(0, Qt::WindowTitleHint |
    9. Qt::WindowSystemMenuHint |
    10. Qt::WindowMinimizeButtonHint );
    11.  
    12. win.show();
    13.  
    14. return app.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 


    But failed,

    Any Idea
    We can't solve problems by using the same kind of thinking we used when we created them

  2. #2
    Join Date
    Sep 2006
    Location
    Valdivia, Chile
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Disabling the Maximize button in QMainWindow ?

    I had tried with diferents Qt Wflags, but it seems no work. So the only way I had found is this:

    // I use this directive in this way:
    #include <qapplication.h>
    #include <qmainwindow.h>

    int main(int argc, char *argv[]) {

    QApplication app( argc, argv );
    QMainWindow *win;
    win = new QMainWindow();

    win->setFixedSize(200, 200);
    app.setMainWidget(win);
    win->show();
    return app.exec();

    }

    If you set the window size, the maximize button won't be shown.
    I hope this be useful. Regards.

  3. The following user says thank you to sir_johann for this useful post:

    sunil.thaha (11th September 2006)

  4. #3
    Join Date
    Nov 2006
    Posts
    72
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Disabling the Maximize button in QMainWindow ?

    I have tried this, but I am using Qt 4.1.4, and my compiler gives me error:

    [HTML]class QApplication' has no member named 'setMainWidget'[/HTML]

    Is there any other way to disable maximize button?

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Disabling the Maximize button in QMainWindow ?

    Quote Originally Posted by Djony View Post
    I have tried this, but I am using Qt 4.1.4, and my compiler gives me error:
    class QApplication' has no member named 'setMainWidget'
    from http://doc.trolltech.com/4.2/porting4.html#qapplication
    QApplication::setMainWidget() is no longer used. When all an application's windows are closed, the application will exit normally.
    The guy, posting the above code probably is using Qt-3.* whereas you are using Qt-4.*.

  6. #5
    Join Date
    Nov 2006
    Posts
    72
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Disabling the Maximize button in QMainWindow ?

    I got that, but the question with maximize button still stands.

  7. #6
    ucomesdag Guest

    Wink Re: Disabling the Maximize button in QMainWindow ?

    This should do it...
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QMainWindow>
    3.  
    4. int main(int argc, char *argv[]) {
    5.  
    6. QApplication app( argc, argv );
    7.  
    8. win.setWindowFlags( Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint);
    9.  
    10. win.show();
    11.  
    12. return app.exec();
    13. };
    To copy to clipboard, switch view to plain text mode 

  8. The following user says thank you to ucomesdag for this useful post:

    Djony (10th January 2007)

  9. #7
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Disabling the Maximize button in QMainWindow ?

    Works well in Windows Xp , but as I mentioned first, It does not work in KDE. KDE seems to ignore the Flags
    We can't solve problems by using the same kind of thinking we used when we created them

  10. #8
    ucomesdag Guest

    Default Re: Disabling the Maximize button in QMainWindow ?

    Quote Originally Posted by sunil.thaha View Post
    Works well in Windows Xp , but as I mentioned first, It does not work in KDE. KDE seems to ignore the Flags
    It got it running fine in KDE maximize button is gone as in windows it's only disabled.

  11. #9
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Disabling the Maximize button in QMainWindow ?

    I am using KDE 3.3.1 with Plastique Theme, See the screen shot. The maximize button is still there
    Attached Images Attached Images
    We can't solve problems by using the same kind of thinking we used when we created them

  12. #10
    Join Date
    Nov 2006
    Posts
    72
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Disabling the Maximize button in QMainWindow ?

    Thank you, ucomesdag! Is there way to make it disappear completely?

  13. #11
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Disabling the Maximize button in QMainWindow ?

    You can set same maximum and minimum size As.

    MainForm *MainFormObj=new MainForm(0);
    MainFormObj->show();

    MainFormObj->setMaximumSize (849,626);
    MainFormObj->setMinimumSize (849,626);

    I think it will work.I m using this on my mac using qt 4.2.2.

  14. #12
    Join Date
    Nov 2006
    Posts
    72
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Disabling the Maximize button in QMainWindow ?

    Tried it. It doesn't work on WinXP.

  15. #13
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Disabling the Maximize button in QMainWindow ?

    what is Happening when you r doing this.
    Is there is an error?
    Actually I am running it correctly and donot know why it is not working in XP.

    check one thing that U also set the geometry of main window as

    MainForm *MainFormObj=new MainForm(0);
    MainFormObj->show();

    MainFormObj->setMaximumSize (849,626);
    MainFormObj->setMinimumSize (849,626);

    MainFormObj->setGeometry(5,42,849,626); //add this line

    Try this.
    Last edited by vishal.chauhan; 10th January 2007 at 13:52. Reason: updated contents

  16. #14
    ucomesdag Guest

    Default Re: Disabling the Maximize button in QMainWindow ?

    Quote Originally Posted by sunil.thaha View Post
    I am using KDE 3.3.1 with Plastique Theme, See the screen shot. The maximize button is still there
    Might be the version of KDE I got 3.5.5 running and it works.

    Quote Originally Posted by Djony View Post
    Thank you, ucomesdag! Is there way to make it disappear completely?
    On windows XP it just disables the button but it doesn't disappear.

  17. #15
    Join Date
    Feb 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Disabling the Maximize button in QMainWindow ?

    Hi Sunil.thaha,

    How did you solve the above problem? Could you manage to make the maximize button disappeared?

    Regards,
    ~NM

  18. #16
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Disabling the Maximize button in QMainWindow ?

    Read about Qt::WindowFlags

  19. #17
    Join Date
    Feb 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Disabling the Maximize button in QMainWindow ?

    hi,

    Those flags are not working properly. those working fine on windows but not on Mac. Even I am not being able to have close button on mac.
    I hv posted my code here. http://www.qtcentre.org/threads/2990...063#post140063


    thanks anyway.

  20. #18
    Join Date
    Sep 2013
    Posts
    11
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: Disabling the Maximize button in QMainWindow ?

    check this example
    http://doc.qt.io/qt-5/qtwidgets-widg...s-example.html

    you should use
    qt::window | qt::windowminimizebuttonhint | qt::closebuttonhint | qt::customizewindowhint


    you can not remove the maximize button without the customizewindowhint

Similar Threads

  1. Replies: 2
    Last Post: 1st August 2006, 11:23
  2. custom maximize button---
    By Naveen in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2006, 14:11
  3. Replies: 18
    Last Post: 22nd February 2006, 21:51
  4. Push button double click
    By curtisw in forum Qt Programming
    Replies: 3
    Last Post: 15th February 2006, 17:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.