48 #include <QGraphicsItem> 49 #include <QGraphicsLayoutItem> 54 #include <QPainterPath> 67 class Text :
public QObject,
public QGraphicsSimpleTextItem,
public QGraphicsLayoutItem
70 Q_INTERFACES(QGraphicsLayoutItem)
75 explicit Text (QGraphicsItem *_parent = 0);
76 Text (
const QString &_text, QGraphicsItem *_parent = 0);
85 QPainterPath
shape ()
const;
88 virtual void paint (QPainter *_painter,
const QStyleOptionGraphicsItem *_option, QWidget *_widget = 0);
118 void setText (QString _text) {text_ = _text; update (); };
121 QString
text () {
return text_; };
126 virtual QSizeF sizeHint ( Qt::SizeHint _which,
const QSizeF & _constraint = QSizeF())
const;
134 QBrush backgroundBrush_;
140 Qt::Alignment alignment_;
virtual QRectF boundingRect() const
Bounding rectangle.
QBrush backgroundBrush()
Returns the current background brush.
virtual void setBackgroundBrush(QBrush _brush)
Sets the background brush.
virtual void setBackgroundPen(QPen _pen)
Sets the background pen.
QString text()
Get displayed text.
void setBackground(bool _leftOut, bool _rightOut)
Enables background painting.
virtual void setGeometry(const QRectF &_rect)
Sets the geometry.
void setText(QString _text)
Set displayed text.
QPen backgroundPen()
Returns the current background pen.
Text(QGraphicsItem *_parent=0)
Constructor.
void setHorizontalStretch(bool _stretch)
Should this widget be stretchable in horizontal direction.
virtual void paint(QPainter *_painter, const QStyleOptionGraphicsItem *_option, QWidget *_widget=0)
Background painting.
void setAlignment(Qt::Alignment _alignment)
Placement of the text in a stretched widget.
QPainterPath shape() const
Returns the shape for proper repainting/event handling.
void clearBackground()
Disables backgorund painting.