diff options
author | Doris Verria <doris.verria@qt.io> | 2020-12-10 01:42:22 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-12-11 13:17:14 +0000 |
commit | a00fb1c9559180bfbcd68b164082ccf555001b74 (patch) | |
tree | 4aeb2ee49b1c4059eb0ac100279799cab12f5af6 /src/widgets | |
parent | 0d72ae726737ff5b1bc9472c1b45f41267327e8e (diff) |
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>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/widgets/qcommandlinkbutton.cpp | 6 | ||||
-rw-r--r-- | src/widgets/widgets/qcommandlinkbutton.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/widgets/widgets/qcommandlinkbutton.cpp b/src/widgets/widgets/qcommandlinkbutton.cpp index e9462ed229..4f0de092be 100644 --- a/src/widgets/widgets/qcommandlinkbutton.cpp +++ b/src/widgets/widgets/qcommandlinkbutton.cpp @@ -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. */ diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h index c48522ee62..2a1ae05807 100644 --- a/src/widgets/widgets/qcommandlinkbutton.h +++ b/src/widgets/widgets/qcommandlinkbutton.h @@ -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; |