Override initStyleOption() for QCommandLinkButton

In QPushButton::initStyleOption() there is no style option feature set
to distinguish QCommandLinkButtons. The QStyleOptionButton::CommandLink
Button feature is only set during the paintEvent, but in some cases we
need to check for this feature before painting.
To fix, override initStyleOption for QCommandLinkButton and set the fea
ture there.

Pick-to: 5.15 6.0
Change-Id: I8831a6be7da642dcf8830812d99681213e7515dc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Doris Verria 2020-12-10 01:42:22 +01:00
parent 86a655387c
commit d3ee976aca
2 changed files with 7 additions and 0 deletions

View File

@ -264,6 +264,12 @@ QSize QCommandLinkButton::minimumSizeHint() const
return size; return size;
} }
void QCommandLinkButton::initStyleOption(QStyleOptionButton *option) const
{
QPushButton::initStyleOption(option);
option->features |= QStyleOptionButton::CommandLinkButton;
}
/*! /*!
Constructs a command link with no text and a \a parent. Constructs a command link with no text and a \a parent.
*/ */

View File

@ -69,6 +69,7 @@ public:
QSize sizeHint() const override; QSize sizeHint() const override;
int heightForWidth(int) const override; int heightForWidth(int) const override;
QSize minimumSizeHint() const override; QSize minimumSizeHint() const override;
void initStyleOption(QStyleOptionButton *option) const override;
protected: protected:
bool event(QEvent *e) override; bool event(QEvent *e) override;