I created a this->setWindowFlags(Qt::FramelessWindowHint);
and so there is no title bar. Therefore, I am implementing my own. I wanted to know, however, before I continue whether there is a standard way to add the close, minimize, and maximize buttons in a native-os looking way (i.e. on windows it should look like the windows close buttons and the same for osx and linux).
Apple calls them Title Bar Buttons. Note that they're named Close, Minimize and Zoom.
QStyle
take a lot of standard icons base on OS style. You can get this icon from current OS style and then draw it by your self.
This is a simple implementation for reference.
class TitleBar : public QWidget
{
Q_OBJECT
public:
explicit TitleBar(QWidget *parent = 0)
:QWidget(parent)
{
QStyle *style = qApp->style();
QIcon closeIcon = style->standardIcon(QStyle::SP_TitleBarCloseButton);
QIcon maxIcon = style->standardIcon(QStyle::SP_TitleBarMaxButton);
QIcon minIcon = style->standardIcon(QStyle::SP_TitleBarMinButton);
QPushButton *min = new QPushButton(this);
QPushButton *max = new QPushButton(this);
QPushButton *close = new QPushButton(this);
min->setIcon(minIcon);
max->setIcon(maxIcon);
close->setIcon(closeIcon);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setSpacing(0);
layout->addWidget(min);
layout->addWidget(max);
layout->addWidget(close);
setLayout(layout);
}
};
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