The layout of the button is platform specific.
Windows - Ok | Cancel | Apply
OS X - Apply | Cancel | Ok
KDE - Ok | Apply | Cancel
GNOME - Apply | Cancel | Ok
There are two ways to force the use of a custom layout.
You can subclass QProxyStyleand override the styleHint method to provide a custom style for QStyle::SH_DialogButtonLayoutstyleHint.
class KdeStyle : public QProxyStyle
{
public:
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const override
{
if (stylehint == SH_DialogButtonLayout)
return QDialogButtonBox::KdeLayout;
return QProxyStyle::styleHint(stylehint, opt, widget, returnData);
}
};
Then apply a custom style to the application.
qApp->setStyle(new KdeStyle());
- . button-layout QDialogButtonBox QMessageBox. : 0 (WinLayout), 1 (MacLayout), 2 (KdeLayout) 3 (GnomeLayout).
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel);
buttonBox->setStyleSheet("* { button-layout: 2 }");