QML Rich Text Editor

Is it possible to create a simple text editor only using QML components?

I am trying to do this with help TextArea, but it seems like it has no way to work with formatted text. Of course, I can do something like this:

ToolButton {
 text: "Bold"
 onClicked: {
     var start = textArea.selectionStart;
     var end = textArea.selectionEnd;
     var text = textArea.getText(start,end);
     text = "<strong>" + text + "</strong>";
     textArea.remove(start,end);
     textArea.insert(start,text);
 }
} 

But I still can’t detect the formatting of the text under the cursor.

I will be glad if anyone can share a piece of code or something.

Any advice would be appreciated.

+4
source share
2 answers

O, :) , QML. ++ $QTDIR/Src/qtquickcontrols/examples/quick/controls/texteditor/

+1

, , TextEdit:

http://qt-project.org/doc/qt-5/qml-qtquick-textedit.html

, Rich Text QML

QtQuick TextEdit QtQuick.Controls TextArea Qt 5.2 textDocument, QQuickTextDocument, , , QTextDocument (, , QWidgets), ++ - TextEdit, ...

( ) JS QML- ( text, HTML, , RegExp...).

0

All Articles