----- Text -----



https://doc.qt.io/qt-6.9/zh/qml-qtquick-layouts-layout.html

 属性 
import QtQuick
import QtQuick.Controls
    
//其他
color: color
antialiasing: bool
    //抗锯齿,只有renderType of Text.NativeRendering 的文本才能禁用
    //默认 true
baseUrl: url
    //指定一个基础 URL,用于解析文本中的相对 URL
    //基础 URL:http://qt-project.org/
    //相对 URL:images/logo.png
    //解析后 URL:http://qt-project.org/images/logo.png
    //基础 URL:http://qt-project.org/content/index.html
    //相对 URL:../images/logo.png
    //解析后 URL:http://qt-project.org/images/logo.png
clip: bool
    //是否被剪切
    //如果文本不适合边界矩形,就会被突然剪切
    //默认 false
font.contextFontMerging: bool
    //如果字体缺少字符,会查找包含该字符的相似字体
    //会逐个查找,代价用性能,获得更好的一致性
    //默认 false
    
//尺寸
width: parent.width; height: parent.height
    //需指定宽高才能使用对齐、换行等
lineHeightMode: Text.FixedHeight
    //固定行高,像素单位
lineHeightMode: Text.ProportionalHeight
    //比例行高,表示几倍行高,默认
lineHeight: real
    //文本的行高,根据lineHeightMode 赋值
maximumLineCount: int
    //限制文本项显示的行数,不适用于富文本
    
//链接
linkColor: color  //链接颜色,不适用于富文本
    
//字体大小
font.pixelSize: int
    //像素单位(适合精准控制),不受设备字体大小影响
font.pointSize: int
    //点单位(适合统一比例)
minimumPixelSize: int
    //按fontSizeMode 属性缩放的文本的最小字体像素大小
    //fontSizeMode 为 Text.FixedSize,或font.pixelSize 为-1,此设置无效
minimumPointSize: int
    //按fontSizeMode 属性缩放的文本的最小字体点大小
    //fontSizeMode 为 Text.FixedSize,或font.pixelSize 为-1,此设置无效
fontSizeMode: enumeration  //如何确定显示文本的字体大小
    //最小边界由minimumPointSize 或minimumPixelSize 属性指定
    //最大边界由font.pixelSize 或font.pointSize  属性指定
    fontSizeMode: Text.FixedSize  //默认
        //使用font.pixelSize 或font.pointSize 指定的大小
    fontSizeMode: Text.HorizontalFit
        //使用适合项目宽度的最大字体大小,直至指定的字体大小,且不包边
    fontSizeMode: Text.VerticalFit
        //使用适合项目高度的最大尺寸,直至指定的尺寸
    fontSizeMode: Text.Fit
        //使用适合项目宽度和高度的最大尺寸,直至指定的尺寸
    
//字体权重,两种值均可(左右值为对应关系)
font.weight: int
    font.weight: 100    font.weight: Font.Thin
    font.weight: 200    font.weight: ExtraLight
    font.weight: 300    font.weight: Font.Light
    font.weight: 400    font.weight: Font.Normal  //默认
    font.weight: 500    font.weight: Font.Medium
    font.weight: 600    font.weight: Font.DemiBold
    font.weight: 700    font.weight: Font.Bold
    font.weight: 800    font.weight: Font.ExtraBold
    font.weight: 900    font.weight: Font.Black
    
//文本格式
text: qsTr("文\n本")  //纯文本
    //支持换行符 \n
text: qsTr("Hello World!")  //富文本
    //支持有限html标签
text: qsTr("See the Qt Project website.")  //嵌入链接
    //支持有限html标签
font.family: "宋体"
    //字体名不区分大小写
font.letterSpacing: real
    //字母间距,允许 负值
font.wordSpacing: real
    //字体或单词间距,允许 负值
elide: enumeration  //长文本省略方式,不适用 富文本
    elide: Text.ElideNone  //默认
    elide: Text.ElideLeft  //省略左边
    elide: Text.ElideMiddle  //省略中间
    elide: Text.ElideRight  //省略右边
font.bold: bool  //粗体
font.italic: bool  //斜体
font.strikeout: bool  //删除线
font.underline: bool  //下划线
font.capitalization: enumeration  //大小写
    font.capitalization: Font.MixedCase  //不改变,默认
    font.capitalization: Font.AllUppercase  //改为大写
    font.capitalization: Font.AllLowercase  //改为小写
    font.capitalization: Font.SmallCaps  //小写改为大写,并且字体变小,大写不变
    font.capitalization: Font.Capitalize  //单词首字母大写
    //支持有限html标签
    
//换行
wrapMode: enumeration
    wrapMode: Text.NoWrap  //不换行,默认
    wrapMode: Text.WordWrap  //仅单词边界换行,即不拆分单词
    wrapMode: Text.WrapAnywhere  //拆分单词换行
    wrapMode: Text.Wrap
        //与 Text.WordWrap 类似,优先不拆分换行,再拆分换行(单词较长时)
    
//text 属性显示方式
textFormat: enumeration
    textFormat: Text.AutoText
        //通过Qt::mightBeRichText() 启发式检测,默认
    textFormat: Text.PlainText
        //所有样式标记都被视为纯文本
    textFormat: Text.StyledText
        //HTML 3.2 中经过优化的基本富文本格式
    textFormat: Text.RichText
        //HTML 4 的子集
    textFormat: Text.MarkdownText
        //CommonMark加上用于表格和任务列表的GitHub扩展
    
//附加文本样式
style: enumeration
    style: Text.Normal  //默认
    style: Text.Outline
    style: Text.Raised
    style: Text.Sunken
    styleColor: color  //附加样式颜色,轮廓颜色
    
//对齐
//水平对齐
horizontalAlignment: Text.AlignHCenter
horizontalAlignment: Text.AlignLeft
horizontalAlignment: Text.AlignRight
horizontalAlignment: Text.AlignJustify  //均匀散开
//垂直对齐
verticalAlignment: Text.AlignVCenter
verticalAlignment: Text.AlignTop
verticalAlignment: Text.AlignBottom
    
//padding
padding: real
topPadding: real
bottomPadding: real
leftPadding: real
rightPadding: real
    


 只读属性 
advance: size
    //???
contentWidth(Height): real  //文本的宽/高度
fontInfo.bold: bool  //粗体状态
fontInfo.family: string  //字体名
fontInfo.italic: bool  //斜体状态
fontInfo.pixelSize: int  //字体像素大小
fontInfo.pointSize: real  //字体点大小
fontInfo.styleName: string  //字体信息的样式名称
fontInfo.weight: int  //字体信息的权重
hoveredLink: string
    //悬停文本中嵌入的链接时,该属性包含链接字符串
    //链接必须是富文本或 HTML 格式
    //hoveredLink 字符串提供对特定链接的访问
lineCount: int  //可见的行数,不支持富文本
truncated: bool  //是否因maximumLineCount 或elide 而被截断


 信号 
lineLaidOut(object line)
    onLineLaidOut
    onLineLaidOut: (line)=> { console.log(line.number) }
        //纯文本或样式文本模式下的排版过程中,每排出一行文本,就会发出该信号
        //实测只要文本内容改变,就会发出该信号
        //这样就有机会在排版时定位和调整行的大小。例如,它可用于创建列或围绕对象布局文本
linkActivated(string link)
    onLinkActivated 
    onLinkActivated: (link)=> console.log(link + " link activated")
        //用户点击文本中嵌入的链接时,将发出该信号
        //链接必须是富文本或 HTML 格式
        //link 字符串提供对特定链接的访问
linkHovered(string link)
    onLinkHovered 
    onLinkHovered: (link)=> console.log(link + " link activated")
        //用户悬停嵌入文本中的链接时,将发出该信号
        //链接必须是富文本或 HTML 格式
        //link 字符串提供对特定链接的访问
//line对象属性
line.number  //行号,只读
line.x(y)  //指定行在 Text 元素中的 x/y 位置
line.width(height)  //指定行的宽/高度
line.implicitWidth  //隐式宽度,只读
line.isLast  //最后一行,只读


 方法 
forceLayout()
    //触发显示文本的重新布局
linkAt(real x, real y)
    //返回x 、y (以内容坐标表示)处的链接字符串
    //如果该处不存在链接,则返回空字符串