I have a floating tool window. It works fine on Windows, but I can't get
rid of the maximise button on Mac OS X. I have tried unsetting
Qt::WindowMaximizeButtonHint
and setting the window to fixed size.
Nothing seems to work.
MyWidget::MyWidget( QWidget* parent )
:QWidget( parent, Qt::Tool | Qt::CustomizeWindowHint )
{
setupUi( this );
setFixedSize( sizeHint() ); // doesn't remove maximise button
setWindowFlags( windowFlags() & ~Qt::WindowMaximizeButtonHint ); // doesn't remove maximise button
}
I don't want to use a frameless window. Any ideas? I am using Qt 4.4.
Launch Qt windowflags example application. Choose Tool
radio button and then check:
It's the only way I found on Mac OS X to achieve what you want BUT you will loose minimize button. There's no other way. That's Mac OS X Window Manager limitation.
Summarizing, there are only five sets of buttons in title bar:
setWindowFlags(Qt::Tool)
setWindowFlags(Qt::Tool
| Qt::WindowTitleHint
| Qt::WindowMaximizeButtonHint
| Qt::WindowCloseButtonHint
| Qt::CustomizeWindowHint)
setWindowFlags(Qt::Tool
| Qt::WindowTitleHint
| Qt::WindowMaximizeButtonHint
| Qt::CustomizeWindowHint)
setWindowFlags(Qt::Tool | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint)
setWindowFlags(Qt::Tool | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint)
This code from Richard Gustavsen of Nokia works in Qt 4.4:
class MyWidget : public QWidget
{
public:
MyWidget::MyWidget( QWidget* parent ) : QWidget(parent, Qt::Tool)
{
}
void setVisible(bool visible)
{
QWidget::setVisible(visible);
ChangeWindowAttributes(qt_mac_window_for(this), kWindowNoAttributes, kWindowFullZoomAttribute);
}
};
Thanks Richard and Nokia!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With