From e8b1e7e3192c258c21f01b85d52b698fe43c73e0 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 16 Sep 2020 17:56:46 +0200 Subject: [PATCH] Fix warning from shadowing virtual function QToolButton::initStyleOption is const. Apply some DRY while at it. Change-Id: If29a52e828bbc2aa58df2852c4c434545acfef3e Reviewed-by: Richard Moe Gustavsen --- .../widgets/qtoolbutton/tst_qtoolbutton.cpp | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp index 6111d5b0dd..32003f2124 100644 --- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp +++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp @@ -61,6 +61,17 @@ private: QPointer m_menu; }; +class MyToolButton : public QToolButton +{ + friend class tst_QToolButton; +public: + void initStyleOption(QStyleOptionToolButton *option) const override + { + QToolButton::initStyleOption(option); + } +}; + + tst_QToolButton::tst_QToolButton() { } @@ -150,16 +161,6 @@ void tst_QToolButton::triggered() void tst_QToolButton::collapseTextOnPriority() { - class MyToolButton : public QToolButton - { - friend class tst_QToolButton; - public: - void initStyleOption(QStyleOptionToolButton *option) - { - QToolButton::initStyleOption(option); - } - }; - MyToolButton button; button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QAction action(button.style()->standardIcon(QStyle::SP_ArrowBack), "test", 0); @@ -178,16 +179,6 @@ void tst_QToolButton::task230994_iconSize() { //we check that the iconsize returned bu initStyleOption is valid //when the toolbutton has no parent - class MyToolButton : public QToolButton - { - friend class tst_QToolButton; - public: - void initStyleOption(QStyleOptionToolButton *option) - { - QToolButton::initStyleOption(option); - } - }; - MyToolButton button; QStyleOptionToolButton option; button.initStyleOption(&option);