Q3CanvasText Class

The Q3CanvasText class provides a text object on a Q3Canvas . 更多...

头: #include <Q3CanvasText>
继承: Q3CanvasItem

公共函数

Q3CanvasText (Q3Canvas * canvas )
Q3CanvasText (const QString & t , Q3Canvas * canvas )
Q3CanvasText (const QString & t , QFont f , Q3Canvas * canvas )
virtual ~Q3CanvasText ()
QColor color () const
QFont font () const
void setColor (const QColor & c )
void setFont (const QFont & f )
void setText (const QString & t )
void setTextFlags (int f )
QString text () const
int textFlags () const

重实现公共函数

virtual QRect boundingRect () const
virtual bool collidesWith (const Q3CanvasItem * i ) const
virtual void moveBy (double dx , double dy )
virtual int rtti () const

重实现保护函数

virtual void draw (QPainter & painter )

详细描述

The Q3CanvasText class provides a text object on a Q3Canvas .

A canvas text item has text with font, color and alignment attributes. The text and font can be set in the constructor or set or changed later with setText () 和 setFont (). The color is set with setColor () and the alignment with setTextFlags (). The text item's bounding rectangle is retrieved with boundingRect ().

The text can be drawn on a painter with draw ().

Like any other canvas item text items can be moved with Q3CanvasItem::move () 和 Q3CanvasItem::moveBy (), or by setting coordinates with Q3CanvasItem::setX (), Q3CanvasItem::setY () 和 Q3CanvasItem::setZ ().

另请参阅 QtCanvas and Porting to Graphics View .

成员函数文档编制

Q3CanvasText:: Q3CanvasText ( Q3Canvas * canvas )

构造 Q3CanvasText with the text "<text>", on canvas .

Q3CanvasText:: Q3CanvasText (const QString & t , Q3Canvas * canvas )

构造 Q3CanvasText with the text t , on canvas canvas .

Q3CanvasText:: Q3CanvasText (const QString & t , QFont f , Q3Canvas * canvas )

构造 Q3CanvasText with the text t and font f , on the canvas canvas .

[虚拟] Q3CanvasText:: ~Q3CanvasText ()

Destroys the canvas text item.

[虚拟] QRect Q3CanvasText:: boundingRect () const

重实现自 Q3CanvasItem::boundingRect ().

Returns the bounding rectangle of the text.

[虚拟] bool Q3CanvasText:: collidesWith (const Q3CanvasItem * i ) const

重实现自 Q3CanvasItem::collidesWith ().

QColor Q3CanvasText:: color () const

Returns the color of the text.

另请参阅 setColor ().

[virtual protected] void Q3CanvasText:: draw ( QPainter & painter )

重实现自 Q3CanvasItem::draw ().

Draws the text using the painter painter .

QFont Q3CanvasText:: font () const

Returns the font in which the text is drawn.

另请参阅 setFont ().

[虚拟] void Q3CanvasText:: moveBy ( double dx , double dy )

重实现自 Q3CanvasItem::moveBy ().

[虚拟] int Q3CanvasText:: rtti () const

重实现自 Q3CanvasItem::rtti ().

Returns 3 ( Q3CanvasItem::Rtti_Text ).

另请参阅 Q3CanvasItem::rtti ().

void Q3CanvasText:: setColor (const QColor & c )

Sets the color of the text to the color c .

另请参阅 color () 和 setFont ().

void Q3CanvasText:: setFont (const QFont & f )

Sets the font in which the text is drawn to font f .

另请参阅 font ().

void Q3CanvasText:: setText (const QString & t )

Sets the text item's text to t . The text may contain newlines.

另请参阅 text (), setFont (), setColor (),和 setTextFlags ().

void Q3CanvasText:: setTextFlags ( int f )

Sets the alignment flags to f . These are a bitwise OR of the flags available to QPainter::drawText () -- see the Qt::AlignmentFlag

另请参阅 textFlags (), setFont (),和 setColor ().

QString Q3CanvasText:: text () const

Returns the text item's text.

另请参阅 setText ().

int Q3CanvasText:: textFlags () const

Returns the currently set alignment flags.

另请参阅 setTextFlags () 和 Qt::AlignmentFlag .