Reputation: 75
Why when I run code bellow, I don't have close button, like on this screenshot?
There is also no close button with other flags, like Qt::WindowMinimizeButtonHint
or Qt::WindowMinMaxButtonsHint
and other.
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget wgt;
wgt.setWindowFlags(Qt::Window | Qt::WindowMaximizeButtonHint);
wgt.show();
return a.exec();
}
Close button is available with wgt.setWindowFlag(Qt::Window)
. Even without wgt.setWindowFlag()
is still available. But as soon as I add second flag like Qt::WindowMaximizeButtonHint
or any other, with button, that must become unavailable, close button become unclickable too.
Upvotes: 2
Views: 3013
Reputation: 4181
Try this:
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget wgt;
wgt.setWindowFlags(Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
wgt.show();
return a.exec();
}
More info:
A window flag is either a type or a hint. A type is used to specify various window-system properties for the widget.
Upvotes: 2