16 #include <qstyleoption.h> 66 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
182 const QMargins m = contentsMargins();
194 if ( align & Qt::AlignLeft || align & Qt::AlignRight )
196 else if ( align & Qt::AlignTop || align & Qt::AlignBottom )
200 sz += QSizeF( mw, mh );
217 const QMargins m = contentsMargins();
220 if ( renderFlags & Qt::AlignLeft || renderFlags & Qt::AlignRight )
224 if ( ( renderFlags & Qt::AlignTop ) || ( renderFlags & Qt::AlignBottom ) )
238 QPainter painter(
this );
239 painter.setClipRegion( event->region() );
243 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter,
this);
245 if ( !contentsRect().contains( event->rect() ) )
247 painter.setClipRegion( event->region() & frameRect() );
248 drawFrame( &painter );
251 painter.setClipRegion( event->region() & contentsRect() );
263 painter->setFont( font() );
264 painter->setPen( palette().color( QPalette::Active, QPalette::Text ) );
272 QRect focusRect = contentsRect().adjusted( m, m, -m + 1, -m + 1);
290 QRect r = contentsRect();
295 r.adjust( m, m, -m, -m );
308 if ( renderFlags & Qt::AlignLeft )
312 else if ( renderFlags & Qt::AlignRight )
314 r.setWidth( r.width() -
indent );
316 else if ( renderFlags & Qt::AlignTop )
320 else if ( renderFlags & Qt::AlignBottom )
322 r.setHeight( r.height() -
indent );
332 if ( frameWidth() <= 0 )
345 #include "moc_qwt_text_label.cpp"
static void drawFocusRect(QPainter *, const QWidget *)
Draw a focus rectangle on a widget using its style.
void setText(const QString &, QwtText::TextFormat textFormat=AutoText)
void clear()
Clear the text and all QwtText attributes.
virtual ~QwtTextLabel()
Destructor.
void draw(QPainter *painter, const QRectF &rect) const
const QwtText & text() const
Return the text.
virtual int heightForWidth(int) const QWT_OVERRIDE
int defaultIndent() const
QwtTextLabel(QWidget *parent=NULL)
virtual QSize minimumSizeHint() const QWT_OVERRIDE
Return a minimum size hint.
bool testPaintAttribute(PaintAttribute) const
double heightForWidth(double width) const
static int horizontalAdvance(const QFontMetrics &, const QString &)
A class representing a text.
virtual void drawContents(QPainter *)
Redraw the text and focus indicator.
virtual void drawText(QPainter *, const QRectF &)
Redraw the text.
QFont font() const
Return the font.
The text has an individual font.
QString plainText() const
virtual QSize sizeHint() const QWT_OVERRIDE
Return a size hint.
virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE
void setPlainText(const QString &)
void setText(const QString &, QwtText::TextFormat textFormat=QwtText::AutoText)