[SailfishDevel] Wanting to port my app, QML questions (TextArea)

Knight Andrew Andrew.Knight at digia.com
Wed Sep 18 12:04:47 UTC 2013


Hi Mark,

Text[1] does indeed support rich text and links, and by extension so do Silica text components. The text property is just get/set though - so if you add to it (i.e. += ), there may be some extra overhead of reprocessing the entire string. Alternatively, you can modify the document itself (the textDocument property) [2], but this is unsupported even though it works.

This would be a good use case for a ListView[3] and a Text item as a delegate. Each time a new text line comes in, you just add it to your model. The ListView only creates a new delegate for the new text, and view can be programmed to scroll away. Delegate instances that leave the view are deleted by default until they come back into view.

[1] http://doc-snapshot.qt-project.org/qt5-stable/qtquick/qml-qtquick2-text.html
[2] http://doc-snapshot.qt-project.org/qt5-stable/qtquick/qquicktextdocument.html
[3] http://doc-snapshot.qt-project.org/qt5-stable/qtquick/qml-qtquick2-listview.html


HTH,
ak

________________________________________
From: devel-bounces at lists.sailfishos.org [devel-bounces at lists.sailfishos.org] on behalf of mark at faultycode.com [mark at faultycode.com]
Sent: Wednesday, September 18, 2013 2:53 PM
To: devel at lists.sailfishos.org
Subject: [SailfishDevel] Wanting to port my app, QML questions (TextArea)

Hi Everyone,

I have written an IRC client for iOS over the last years, and I am at a
point where I'd like to choose a second platform to port my app over to.
I've always been fond of Qt, but lost interest in it when Nokia
switched to windows phone. Thus, I never got around to learning QML,
which means I only have knowledge of making GUI's with QWidgets.
However, now with Jolla, I'm really interested in starting my port.

I have a few questions/concerns before I start porting.

On the iOS side of things, I paste all my IRC messages into a textView
(UITextView for the people here that know).
As of iOS 7, I use the new TextKit features. That is, I can take a
message coming from the TCP socket, make an Attributed String out of it
(I guess a rich string in the Qt world), apply colours, underlining,
bold etc to specific words depending on the colour codes in the message,
then finally append it to the textView.

I've been skimming through the QML components for Sailfish, and I've
found the TextArea component. There is a string property to it, but I
don't know if I can simply append data to it (specifically rich text
data). It seems to me it's either read, or set.

Is the TextArea string property modifiable, or is it immutable? If it's
immutable, then perhaps I need to look at webkit.
Secondly, the textView in iOS is capable of having URL links applied to
ranges of text. Is that also possible with TextArea?

In general, I prefer not to use Webkit, since my html and javascript
skills are really lacking. Hence why I have been using rich text editing
in my iOS app. However, if there is no other possibility, then I just
might have to go the webkit route.

Those are my biggest questions really. QML is completely new to me, but
seems like a fun and powerful thing to learn.

Thanks for you help,

-Mark
_______________________________________________
SailfishOS.org Devel mailing list


More information about the Devel mailing list