QML Text element

Author: Yiqu, Ersanli
Personal Wechat ID: iwaleon
Wechat Official Account: Efficient Programmer

In QML, Text and Label are two commonly used elements (Label inherits from Text), which are used to display text content. Although they look similar, there are some differences in usage and functionality.

For the Text element, the text and font attributes are more important. Once the text and font are specified, the initialized width and height will be automatically calculated. Here are some common Text properties:

  • text: the text content to be displayed
  • color: text color
  • font.family: font style
  • font.pointSize: font size
  • horizontalAlignment: horizontal alignment
  • verticalAlignment: vertical alignment

Unlike Text, Label extends it with styles and fonts, and supports more style options, such as background.

The complete mind map is as follows:

insert image description here

base text

Creating text is easy with Text, which can be defined like this:

Guess you like

Origin blog.csdn.net/u011012932/article/details/130977326