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
Code:
#include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[]) {
Qt::WindowSystemMenuHint |
Qt::WindowMinimizeButtonHint );
win.show();
return app.exec();
}
But failed,
Any Idea
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.
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?
Re: Disabling the Maximize button in QMainWindow ?
Quote:
Originally Posted by
Djony
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
The guy, posting the above code probably is using Qt-3.* whereas you are using Qt-4.*.
Re: Disabling the Maximize button in QMainWindow ?
I got that, but the question with maximize button still stands.
Re: Disabling the Maximize button in QMainWindow ?
This should do it...;)
Code:
#include <QtGui/QApplication>
#include <QMainWindow>
int main(int argc, char *argv[]) {
win.setWindowFlags( Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint);
win.show();
return app.exec();
};
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 :confused:
Re: Disabling the Maximize button in QMainWindow ?
Quote:
Originally Posted by
sunil.thaha
Works well in Windows Xp , but as I mentioned first, It does not work in KDE. KDE seems to ignore the Flags :confused:
It got it running fine in KDE maximize button is gone as in windows it's only disabled.
1 Attachment(s)
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
Re: Disabling the Maximize button in QMainWindow ?
Thank you, ucomesdag! Is there way to make it disappear completely?
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.
Re: Disabling the Maximize button in QMainWindow ?
Tried it. It doesn't work on WinXP.
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.
Re: Disabling the Maximize button in QMainWindow ?
Quote:
Originally Posted by
sunil.thaha
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
Thank you, ucomesdag! Is there way to make it disappear completely?
On windows XP it just disables the button but it doesn't disappear.
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
Re: Disabling the Maximize button in QMainWindow ?
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.
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