diff --git a/src/lib/tabwidget/combotabbar.cpp b/src/lib/tabwidget/combotabbar.cpp index f4162ea16..5bce9f321 100644 --- a/src/lib/tabwidget/combotabbar.cpp +++ b/src/lib/tabwidget/combotabbar.cpp @@ -1816,6 +1816,15 @@ CloseButton::CloseButton(QWidget* parent) setObjectName("combotabbar_tabs_close_button"); setFocusPolicy(Qt::NoFocus); setCursor(Qt::ArrowCursor); + resize(sizeHint()); +} + +QSize CloseButton::sizeHint() const +{ + ensurePolished(); + int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, nullptr, this); + int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, nullptr, this); + return QSize(width, height); } void CloseButton::enterEvent(QEvent* event) diff --git a/src/lib/tabwidget/combotabbar.h b/src/lib/tabwidget/combotabbar.h index 52f39db77..1018aa793 100644 --- a/src/lib/tabwidget/combotabbar.h +++ b/src/lib/tabwidget/combotabbar.h @@ -361,10 +361,12 @@ class CloseButton : public QAbstractButton Q_OBJECT public: - CloseButton(QWidget* parent = 0); + CloseButton(QWidget *parent = nullptr); - void enterEvent(QEvent* event); - void leaveEvent(QEvent* event); - void paintEvent(QPaintEvent* event); + QSize sizeHint() const override; + + void enterEvent(QEvent *event) override; + void leaveEvent(QEvent *event) override; + void paintEvent(QPaintEvent *event) override; }; #endif // COMBOTABBAR_H