Add an extra minimum size hint, since Qt behaviour is broken by design

* The Qt behaviour is that if you call setMinimumSize on a widget, then
  the minimumSizeHint is IGNORED. So it is impossible to say "use this
  minimum size, unless the widget wants a higher minimum size".
* So instead we do this ourselves in RDLabel. Sigh.
This commit is contained in:
baldurk
2017-11-21 18:57:10 +00:00
parent 8fb7620678
commit 1f9a2e340c
2 changed files with 11 additions and 0 deletions
+8
View File
@@ -57,6 +57,8 @@ QSize RDLabel::minimumSizeHint() const
{
QSize sz = QLabel::minimumSizeHint();
modifySizeHint(sz);
if(m_minSizeHint.isValid())
sz = sz.expandedTo(m_minSizeHint);
return sz;
}
@@ -87,6 +89,12 @@ QString RDLabel::text() const
return QLabel::text();
}
void RDLabel::setMinimumSizeHint(const QSize &sz)
{
m_minSizeHint = sz;
updateGeometry();
}
void RDLabel::mousePressEvent(QMouseEvent *event)
{
emit(clicked(event));
+3
View File
@@ -39,6 +39,7 @@ public:
void setText(const QString &text);
QString text() const;
void setMinimumSizeHint(const QSize &sz);
void setPreserveAspectRatio(bool preserve) { m_preserveRatio = preserve; }
bool preserveAspectRatio() { return m_preserveRatio; }
signals:
@@ -65,5 +66,7 @@ protected:
bool m_preserveRatio = false;
bool m_hover = false;
QSize m_minSizeHint;
QVariant m_variant;
};