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.

Change-Id: I8831a6be7da642dcf8830812d99681213e7515dc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit d3ee976acab59019fdd781691f29e6f12e4dedc8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Doris Verria 2020-12-10 01:42:22 +01:00 committed by Qt Cherry-pick Bot
parent 0d72ae7267
commit a00fb1c955
2 changed files with 7 additions and 0 deletions

View File

@ -264,6 +264,12 @@ QSize QCommandLinkButton::minimumSizeHint() const
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.
*/

View File

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