From 1f27c89becd79f47f54adf2095dc42461fc0276c Mon Sep 17 00:00:00 2001 From: Johannes Hilden Date: Fri, 18 Mar 2016 23:44:40 +0300 Subject: [PATCH] borrow implementation of sizeHint from QPushButton --- flatbutton.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flatbutton.cpp b/flatbutton.cpp index 4ab7ffe..84f858b 100644 --- a/flatbutton.cpp +++ b/flatbutton.cpp @@ -40,15 +40,16 @@ QSize FlatButton::sizeHint() const h = qMax(h, ih); } #endif + QString s(text()); bool empty = s.isEmpty(); if (empty) s = QString::fromLatin1("XXXX"); QFontMetrics fm = fontMetrics(); QSize sz = fm.size(Qt::TextShowMnemonic, s); - if(!empty || !w) + if (!empty || !w) w += sz.width(); - if(!empty || !h) + if (!empty || !h) h = qMax(h, sz.height()); return (style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), this). expandedTo(QApplication::globalStrut()));