[Development] Rich Text Editor using QML
Sze Howe Koh
szehowe.koh at gmail.com
Sat Nov 15 00:15:09 CET 2014
On 15 November 2014 03:58, André Pönitz <apoenitz at t-online.de> wrote:
> On Fri, Nov 14, 2014 at 10:06:32AM +0100, Yann Levreau wrote:
> > Hi everybody!
> > I am starting a new project and I am looking for some advice about what
> > kind of Qt/QML controls I should use. The purpose is to develop an rich
> > text editor using QML. Basically I am going to develop IDE features.
> > Until now I have tried the TextArea QML Control. Using this control I get
> > a
> > QQuickTextDocument and QTextDocument on the C++ side.
> > Am I in the right direction ? Is there any limitations using this
> > control that I should know ? Or maybe there is better way to implement
> > this (using QWebView or a simple QTextEdit, ... ).
> On the Widget side the proper choice for an text editor base would be
In C++, I would use a QTextEdit instead of a QPlainTextEdit, because
QTextEdit supports rich text but QPlainTextEdit doesn't.
The QSyntaxHighligher class is useful too.
There are examples available in the documentation:
- Code Editor Example:
- Syntax Highlighter Example:
Or, for a real-world example of an IDE, see the Qt Creator source code:
In QML, yes TextArea would be the best base type. One "limitation" I
can think of is that you can't write pure QML -- QQuickTextDocument
needs to be accessed from C++
interaction is very common so this may not be an issue. I haven't used
Qt Quick Controls much so I can't say whether it's easier to develop
your project in QML or C++.
By the way, this discussion should be happening on the Interest
mailing list. The Development mailing list is for posts about
developing Qt itself. I've included Interest in the CC field -- please
remove Development if you reply.
More information about the Development