borrow implementation of sizeHint from QPushButton
This commit is contained in:
parent
9f640ff6ca
commit
1f27c89bec
|
@ -40,15 +40,16 @@ QSize FlatButton::sizeHint() const
|
||||||
h = qMax(h, ih);
|
h = qMax(h, ih);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QString s(text());
|
QString s(text());
|
||||||
bool empty = s.isEmpty();
|
bool empty = s.isEmpty();
|
||||||
if (empty)
|
if (empty)
|
||||||
s = QString::fromLatin1("XXXX");
|
s = QString::fromLatin1("XXXX");
|
||||||
QFontMetrics fm = fontMetrics();
|
QFontMetrics fm = fontMetrics();
|
||||||
QSize sz = fm.size(Qt::TextShowMnemonic, s);
|
QSize sz = fm.size(Qt::TextShowMnemonic, s);
|
||||||
if(!empty || !w)
|
if (!empty || !w)
|
||||||
w += sz.width();
|
w += sz.width();
|
||||||
if(!empty || !h)
|
if (!empty || !h)
|
||||||
h = qMax(h, sz.height());
|
h = qMax(h, sz.height());
|
||||||
return (style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), this).
|
return (style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), this).
|
||||||
expandedTo(QApplication::globalStrut()));
|
expandedTo(QApplication::globalStrut()));
|
||||||
|
|
Loading…
Reference in New Issue