| Home · All Classes · Main Classes · Deprecated |
MLabel provides functionality for displaying text. More...


Public Slots | |
| void | setText (const QString &text) |
Signals | |
| void | linkActivated (const QString &link) |
Public Member Functions | |
| MLabel (QGraphicsItem *parent=0, MLabelModel *model=0) | |
| MLabel (QString const &text, QGraphicsItem *parent=0) | |
| virtual | ~MLabel () |
| void | setAlignment (Qt::Alignment alignment) |
| Qt::Alignment | alignment () const |
| QTextOption::WrapMode | wrapMode () const |
| void | setWrapMode (QTextOption::WrapMode wrapMode) |
| void | setWordWrap (bool wrap) |
| bool | wordWrap () const |
| QString | text () const |
| void | setTextElide (bool elide) |
| bool | textElide () const |
| void | setFont (const QFont &font) |
| QFont | font () const |
| void | setColor (const QColor &color) |
| QColor | color () const |
| void | addHighlighter (MLabelHighlighter *highlighter) |
| void | removeHighlighter (MLabelHighlighter *highlighter) |
| void | removeAllHighlighters () |
| void | setTextFormat (Qt::TextFormat textFormat) |
| Qt::TextFormat | textFormat () const |
Properties | |
| Qt::Alignment | alignment |
| bool | wordWrap |
| QTextOption::WrapMode | wrapMode |
| bool | textElide |
| QString | text |
| QColor | color |
| Qt::TextFormat | textFormat |
MLabel provides functionality for displaying text.
MLabel provides functionality for displaying text. It can display plain text as well as rich text. The positioning of the text can be changed using setAlignment(). The appearance of the text can be tweaked using setTextDirection(), setWordWrap() and setTextElide().
Following list summarizes the functionality of MLabel:
Simple label:
//simple label with text MLabel* label = new MLabel("Simple label"); //set/change the text of label label->setText("Text");
Rich label:
//rich label with bold text. MLabel* label = new MLabel("Rich <b>bold</b> label"); //manual line changes in rich label label->setText("row1<br><i>row2</i><br>row3");
Rich label with custom text color:
QString styledText = "<style>red{color:#FF0000;}</style> <red>Rich</red> label can be <red>styled</red>."; MLabel* label = new MLabel(styledText);
Links in rich label:
//create label with a link QString text = "Rich label can contain <a href=\"http://www.nokia.com\"> links </a>."; MLabel* label = new MLabel(styledText); //connect to signal to receive notification when user clicks a link in label connect(label, SIGNAL(linkActivated(QString)), this, SLOT(linkActivated(QString)));
Definition at line 122 of file corelib/widgets/mlabel.h.
| MLabel::MLabel | ( | QGraphicsItem * | parent = 0, |
|
| MLabelModel * | model = 0 | |||
| ) |
Constructs label widget.
| parent | optional parent. | |
| model | optional model. |
Definition at line 32 of file mlabel.cpp.
:
MWidgetController(new MLabelPrivate, model == NULL ? new MLabelModel : model, parent)
{
grabGesture(Qt::TapAndHoldGesture);
}
| MLabel::MLabel | ( | QString const & | text, | |
| QGraphicsItem * | parent = 0 | |||
| ) | [explicit] |
Constructs a label with a text.
| text | Label text. | |
| parent | Optional parent. |
Definition at line 38 of file mlabel.cpp.
:
MWidgetController(new MLabelPrivate, new MLabelModel, parent)
{
grabGesture(Qt::TapAndHoldGesture);
setText(text);
}

| MLabel::~MLabel | ( | ) | [virtual] |
| void MLabel::addHighlighter | ( | MLabelHighlighter * | highlighter | ) |
Add highlighter object to mlabel.
Definition at line 165 of file mlabel.cpp.
{
model()->addHighlighter(highlighter);
}

| Qt::Alignment MLabel::alignment | ( | ) | const |
Returns the current alignmentation.
| QColor MLabel::color | ( | ) | const |
Returns the color previously set with setColor().
| QFont MLabel::font | ( | ) | const |
Return the current font.
The current font is either a font previously set with setFont() or if nothing has been manually set the one that has been defined in css for this particular label.
Overrides QGraphicsWidget::font() const.
Definition at line 132 of file mlabel.cpp.

| void MLabel::linkActivated | ( | const QString & | link | ) | [signal] |
A signal which is emitted when an anchor in the label is clicked.
link contains the clicked link. The signal is only emitted when the link is defined using anchor "<a href=\"http://www.nokia.com"> nokia " html tag.
| void MLabel::removeAllHighlighters | ( | ) |
Remove all highlighter objects from mlabel.
Definition at line 175 of file mlabel.cpp.
{
model()->setHighlighters(QList<MLabelHighlighter *>());
}

| void MLabel::removeHighlighter | ( | MLabelHighlighter * | highlighter | ) |
Remove highlighter object from mlabel.
Definition at line 170 of file mlabel.cpp.
{
model()->removeHighlighter(highlighter);
}

| void MLabel::setAlignment | ( | Qt::Alignment | alignment | ) |
Set an alignmentation for the text.
Definition at line 80 of file mlabel.cpp.

| void MLabel::setColor | ( | const QColor & | color | ) |
Set the text color for the MLabel.
By default MLabel uses color defined in the css file. This method can be used to change the color from code. Giving invalid color (QColor()) takes font in the css back to use.
Definition at line 141 of file mlabel.cpp.
{
model()->setColor(color);
}

| void MLabel::setFont | ( | const QFont & | font | ) |
Set the font used in MLabel.
By default MLabel uses font defined in the css file. This method can be used to change the font from code.
Overrides QGraphicsWidget::setFont(const QFont &font)
Definition at line 125 of file mlabel.cpp.
{
model()->setUseModelFont(true);
model()->setFont(font);
QGraphicsWidget::setFont(font);
}

| void MLabel::setText | ( | const QString & | text | ) | [slot] |
Set text for the label.
Definition at line 75 of file mlabel.cpp.
{
model()->setText(text);
}

| void MLabel::setTextElide | ( | bool | elide | ) |
Enable/disable automatic text eliding.
If the label doesn't have enough space to show the full text on one line, the will be elided with three dots.
Definition at line 115 of file mlabel.cpp.
{
model()->setTextElide(elide);
}

| void MLabel::setTextFormat | ( | Qt::TextFormat | textFormat | ) |
Set text format.
This function sets the format in which the label text is displayed. Calling this function with Qt::PlainText or Qt::RichText is used to turn off auto-recognition of text format, calling with Qt::AutoText turns auto-recognition back on.
Definition at line 155 of file mlabel.cpp.
{
model()->setTextFormat(textFormat);
}

| void MLabel::setWordWrap | ( | bool | wrap | ) |
Enable/disable automatic word wrapping.
If true, wrapping is done according to the mode set with setWrapMode.
Definition at line 95 of file mlabel.cpp.
{
model()->setWordWrap(wrap);
}

| void MLabel::setWrapMode | ( | QTextOption::WrapMode | wrapMode | ) |
Set word wrapping mode.
Definition at line 90 of file mlabel.cpp.

| QString MLabel::text | ( | ) | const |
Returns the current text.
| bool MLabel::textElide | ( | ) | const |
Returns the elide mode of the label.
| Qt::TextFormat MLabel::textFormat | ( | ) | const |
Returns the text format.
This method returns the format in which MLabel displays its text. Note that this function does not give information about the actual format of the label text string, only about the way it is displayed.
| bool MLabel::wordWrap | ( | ) | const |
Returns whether the text in label will be wrapped or not.
If the label doesn't have enough space to show the full text on one line, the text will be wrapped to multiple lines.
| QTextOption::WrapMode MLabel::wrapMode | ( | ) | const |
Returns wrapping mode for the text in the label.
If the label doesn't have enough space to show the full text on one line, the text will be wrapped to multiple lines if a mode with wrapping behavior is active.
MLabel::alignment [read, write] |
Alignmentation of the label.
See MLabelModel::alignment for details.
Definition at line 133 of file corelib/widgets/mlabel.h.
MLabel::color [read, write] |
Color of the label text.
See MLabelModel::color for details.
Definition at line 171 of file corelib/widgets/mlabel.h.
MLabel::text [read, write] |
Text of the label.
See MLabelModel::text for details.
Definition at line 163 of file corelib/widgets/mlabel.h.
MLabel::textElide [read, write] |
Text eliding mode of the label.
See MLabelModel::textElide for details.
Definition at line 155 of file corelib/widgets/mlabel.h.
MLabel::textFormat [read, write] |
Format the label text is displayed in.
This property is used for deciding whether a text string should be interpreted as plain text or rich text. Supported text formats are Qt::PlainText, Qt::RichText and Qt::AutoText. The default format is Qt::AutoText, which causes MLabel to guess the format of the text on a case-by-case basis.
Definition at line 182 of file corelib/widgets/mlabel.h.
MLabel::wordWrap [read, write] |
Is word wrapping done or not.
Definition at line 139 of file corelib/widgets/mlabel.h.
QTextOption::WrapMode MLabel::wrapMode [read, write] |
Definition at line 147 of file corelib/widgets/mlabel.h.
| Copyright © 2010 Nokia Corporation | Generated on Thu Nov 4 2010 18:14:25 (PDT) Doxygen 1.7.1 |
MeeGo Touch |