mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
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:
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user