diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 9277c5e42ab..ded02a756a0 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -56,6 +56,20 @@ HMENU qt_getWindowsSystemMenu(const QWidget *w) } #endif +static_assert(qToUnderlying(QMessageBox::ButtonRole::NRoles) == + qToUnderlying(QDialogButtonBox::ButtonRole::NRoles), + "QMessageBox::ButtonRole and QDialogButtonBox::ButtonRole out of sync!"); + +static_assert(std::is_same_v, + std::underlying_type_t>); + +// StandardButton enums have different underlying types +// => qToUnderlying and std::is_same_v won't work +// ### Qt 7: make them have the same underlying type +static_assert(static_cast(QMessageBox::StandardButton::LastButton) == + static_cast(QDialogButtonBox::StandardButton::LastButton), + "QMessageBox::StandardButton and QDialogButtonBox::StandardButton out of sync!"); + enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6, Old_Ignore = 7, Old_YesAll = 8, Old_NoAll = 9, Old_ButtonMask = 0xFF, NewButtonMask = 0xFFFFFC00 }; diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h index 5db4f6e67e9..897f02c5fc2 100644 --- a/src/widgets/dialogs/qmessagebox.h +++ b/src/widgets/dialogs/qmessagebox.h @@ -66,9 +66,6 @@ public: NRoles }; Q_ENUM(ButtonRole) - static_assert(static_cast(ButtonRole::NRoles) == - static_cast(QDialogButtonBox::ButtonRole::NRoles), - "QMessageBox::ButtonRole and QDialogButtonBox::ButtonRole out of sync!"); enum StandardButton { // keep this in sync with QDialogButtonBox::StandardButton and QPlatformDialogHelper::StandardButton @@ -104,10 +101,6 @@ public: ButtonMask = ~FlagMask // obsolete }; Q_ENUM(StandardButton); - static_assert(static_cast(StandardButton::LastButton) == - static_cast(QDialogButtonBox::StandardButton::LastButton), - "QMessageBox::StandardButton and QDialogButtonBox::StandardButton out of sync!"); - #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) typedef StandardButton Button;