PDA

View Full Version : window buttons



jaca
11th August 2012, 22:17
How to disconnect buttons (setEnabled(false)) close, maximize and minimize of QMainWindow? Or make the window size fixed.

ObiWanKenobe
11th August 2012, 22:30
setWindowFlags ( Qt::WindowFlags type )

ZikO
11th August 2012, 23:12
How to disconnect buttons (setEnabled(false)) close, maximize and minimize of QMainWindow? Or make the window size fixed.
I don't know if it's possible to do what you want to. If you call setWindowFlags(Qt::CustomizeWindowHint) you remove all buttons and a title bar from a window but you still can resize it. Each flag from Qt namespace simply adds a button one by one and other window features. You should read this:
http://doc.qt.nokia.com/4.7-snapshot/qt.html#WindowType-enum

Perhaps there is a lower level hard coding fulfil this but I don't know about it.

jaca
12th August 2012, 02:08
Works well doing:
setWindowFlags( Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::MSWindowsFixedSizeDialogHint);
But, using the class QMainWindow some event is enabled and you can resize the window. An attached image shows where the event occurs.
8125

ZikO
12th August 2012, 02:58
Hi. Good job with what you have achieved so far :). In your example though I still could still resize a window. I have also found the function setFixedSize(windoWidth, windowHeigth). If you use it as follows:

MainWindow w;
w.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint ); // or whatever other flags
w.setFixedSize(w.width(),w.height());
w.show();

You may have your window fixed but I still have seen the "resize" icon at the window's corner.

Reference:
http://stackoverflow.com/questions/696209/in-qt-how-to-make-the-qdialog-non-resizeable-and-have-a-fixed-size