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