Qt 4.8
Static Public Functions | List of all members
Text Class Reference

The Text item allows you to add formatted text to a scene. More...

Inheritance diagram for Text:
CharacterData Item Node CDATA

Static Public Functions

static QScriptValue isElementContentWhitespace (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue prototype (QScriptEngine *)
 
static QScriptValue wholeText (QScriptContext *context, QScriptEngine *engine)
 
- Static Public Functions inherited from CharacterData
static QScriptValue length (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue prototype (QScriptEngine *)
 
- Static Public Functions inherited from Node
static QScriptValue attributes (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue childNodes (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue create (QScriptEngine *, NodeImpl *)
 
static QScriptValue firstChild (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue lastChild (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue nextSibling (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue nodeName (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue nodeType (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue nodeValue (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue parentNode (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue previousSibling (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue prototype (QScriptEngine *)
 

Additional Inherited Members

- Public Functions inherited from Node
bool isNull () const
 
 Node ()
 
 Node (const Node &o)
 
 ~Node ()
 
- Public Variables inherited from Node
NodeImpld
 

Detailed Description

The Text item allows you to add formatted text to a scene.

Since
4.7

Text items can display both plain and rich text. For example, red text with a specific font and size can be defined like this:

text: "Hello World!"
font.family: "Helvetica"
font.pointSize: 24
color: "red"
}

Rich text is defined using HTML-style markup:

text: "<b>Hello</b> <i>World!</i>"
}
declarative-text.png

If height and width are not explicitly set, Text will attempt to determine how much room is needed and set it accordingly. Unless wrapMode is set, it will always prefer width to height (all text will be placed on a single line).

The elide property can alternatively be used to fit a single line of plain text to a set width.

Note that the Supported HTML Subset is limited. Also, if the text contains HTML img tags that load remote images, the text is reloaded.

Text provides read-only text. For editable text, see TextEdit .

See also
{declarative/text/fonts}{Fonts example}

Definition at line 294 of file qdeclarativexmlhttprequest.cpp.

Functions

◆ isElementContentWhitespace()

QScriptValue Text::isElementContentWhitespace ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 583 of file qdeclarativexmlhttprequest.cpp.

584 {
585  Node node = qscriptvalue_cast<Node>(context->thisObject());
586  if (node.isNull()) return engine->undefinedValue();
587 
588  return node.d->data.trimmed().isEmpty();
589 }
T qscriptvalue_cast(const QScriptValue &)
bool isNull() const
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.

◆ prototype()

QScriptValue Text::prototype ( QScriptEngine engine)
static

Definition at line 599 of file qdeclarativexmlhttprequest.cpp.

Referenced by Node::create(), and CDATA::prototype().

600 {
601  QScriptValue proto = engine->newObject();
602  proto.setPrototype(CharacterData::prototype(engine));
603 
606 
607  return proto;
608 }
QScriptValue newFunction(FunctionSignature signature, int length=0)
Creates a QScriptValue that wraps a native (C++) function.
static QScriptValue isElementContentWhitespace(QScriptContext *context, QScriptEngine *engine)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QScriptValue newObject()
Creates a QtScript object of class Object.
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue&#39;s property with the given name to the given value.
void setPrototype(const QScriptValue &prototype)
If this QScriptValue is an object, sets the internal prototype (__proto__ property) of this object to...
static QScriptValue wholeText(QScriptContext *context, QScriptEngine *engine)
static QScriptValue prototype(QScriptEngine *)
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ wholeText()

QScriptValue Text::wholeText ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 591 of file qdeclarativexmlhttprequest.cpp.

592 {
593  Node node = qscriptvalue_cast<Node>(context->thisObject());
594  if (node.isNull()) return engine->undefinedValue();
595 
596  return node.d->data;
597 }
T qscriptvalue_cast(const QScriptValue &)
bool isNull() const
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.

The documentation for this class was generated from the following file: