-a size hint. hardcoded because here we can't really have infos but is already better than nothing

-if the alignment of lablels is left, paint with a point instead of a rect, so won't clip away the text

svn path=/trunk/KDE/kdelibs/; revision=1083230
This commit is contained in:
Marco Martin 2010-01-31 21:30:41 +00:00
parent 1ae27ef35f
commit 989df58b2b
2 changed files with 15 additions and 1 deletions

View File

@ -82,7 +82,11 @@ void MeterPrivate::text(QPainter *p, int index)
align = alignments[index];
}
if (elementRect.width() > elementRect.height()) {
p->drawText(elementRect, align, text);
if (align&Qt::AlignLeft) {
p->drawText(elementRect.bottomLeft(), text);
} else {
p->drawText(elementRect, align, text);
}
} else {
p->save();
QPointF rotateCenter(
@ -521,6 +525,15 @@ void Meter::paint(QPainter *p,
}
}
QSizeF Meter::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{return QGraphicsWidget::sizeHint(which, constraint);
if (which == Qt::PreferredSize) {
return QSizeF(200, 32);
} else {
return QGraphicsWidget::sizeHint(which, constraint);
}
}
} // End of namepace
#include "meter.moc"

View File

@ -208,6 +208,7 @@ protected:
virtual void paint(QPainter *p,
const QStyleOptionGraphicsItem *option,
QWidget *widget = 0);
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
private:
MeterPrivate *const d;