Ok guy.
Im trying to make a text editor with v-play and qml but i can not for the love of life find a solution to this problem.
I have created a very simple editor with line numbers (Im still figuring out all the sizing etc and getting the line height of the AppTextEdit text and the number item to the left). The problem is that no matter what options or properties i have tried to change and look up online i can’t change the spacing between lines (line height in css) or the spacing between each line. Can anyone help pleeeeeeez. Thank you
import Felgo 3.0
import QtQuick 2.6
import Qt.labs.controls 1.0
Item {
id: editorRoot
// property var linesModel
// property var myView
// property var listView: listView
property string fontFace: “Monospace”
property var cursor: Qt.IBeamCursor
property bool ctrl: false
property int fontSize: swt(2.4)
property var lineHeight: fontMetrics.lineSpacing
property alias font: textEdit.font
property alias text: textEdit.text
// property var lineNumbersWidth: fontMetrics.advanceWidth(” + (myView ? myView.lines() : “0”))
property var editorFont: editorRoot.fontSize + “pt \”” + editorRoot.fontFace + “\”” + “, monospace”
property var spaceWidth: 25
property var tabWidth: spaceWidth * 4
property real numbersColumnWidth: sw(5)
onEditorFontChanged: {
editorRoot.spaceWidth = fontMetrics.advanceWidth(‘ ‘);
}
FontMetrics {
id: fontMetrics
font.family: editorRoot.fontFace
font.pointSize: editorRoot.fontSize
}
anchors.fill: parent
Rectangle {
height: parent.height
anchors.right: parent.right
width: 1
color: “#ddd”
}
Column {
width: parent.width
Repeater {
model: editorRoot.height / editorRoot.lineHeight
delegate: Text {
id: text
width: numbersColumnWidth
height: editorRoot.lineHeight / 100 * 98
color: “#666”
font: textEdit.font
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering
text: index + 1
}
}
}
Rectangle {
anchors {
fill: textEdit
leftMargin: -10
}
}
AppTextEdit {
id: textEdit
property int currentLine: text.substring(0, cursorPosition).split(/\r\n|\r|\n/).length – 1
textMargin: 30
font.pixelSize: {
wordSpacing:5
editorRoot.fontSize
}
wrapMode: Text.WordWrap
anchors {
fill: parent
topMargin: 2
leftMargin: numbersColumnWidth + 10
}
selectByKeyboard: true
selectByMouse: true
textFormat: Qt.PlainText
}
Column {
anchors.fill: parent
Repeater {
model: editorRoot.height / editorRoot.lineHeight
Rectangle {
color: index === textEdit.currentextEdittLine ? “blue” : “transparent”
height: editorRoot.lineHeigh
width: editorRoot.width
opacity: 0.2
}
}
}
}