承接上篇文章,今天给编辑器加了一个小功能:显示行号。 当然也有我想偷懒的成分(其实是我菜),实现过程异常简单,如下:
Column{
id:showlinecount
x: 15
y: 15
width: 24
height: 660
Repeater{
model: t1.lineCount
Rectangle{
width: parent.width
height: 36.5
color: "#E5E4E2"
Text{
id:showlinenum
anchors{
horizontalCenter: parent.horizontalCenter
}
text: index+1
color: "black"
}
}
}
}
创建一个柱,利用lineCount获取到TextEdit中text的行号,Repeater创