Fix warning from shadowing virtual function

QToolButton::initStyleOption is const. Apply some DRY while at it.

Change-Id: If29a52e828bbc2aa58df2852c4c434545acfef3e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Volker Hilsheimer 2020-09-16 17:56:46 +02:00
parent 615b92008a
commit e8b1e7e319

View File

@ -61,6 +61,17 @@ private:
QPointer<QWidget> 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);