[immodule-qt] Some more things for Qt 4

Lars Knoll lars at trolltech.com
Mon Oct 25 11:32:55 EEST 2004


On Monday 25 October 2004 08:41, Anuradha Ratnaweera wrote:
> On Sun, 24 Oct 2004 18:26:03 +0900, Daisuke Kameda
>
> <kaminmat at cc.rim.or.jp> wrote:
> > I feel this solution is good. Please tell me example usage about
> > surrounding text for more detailed discussion. Especially, I want to know
> > about how getting and using data from QVAriant object.
>
> In GTK, when queried for surrounding text, it returns a _copy_ of the
> actual text which needs to be free()ed.  But this is not necessary,
> and expensive, to malloc() and strcpy() for each call, so returning a
> pointer to actual text would have been efficient (IMHO only).  And if
> one really wants, then doing a malloc(), strycpy() and free() would
> have been triviel.
>
> I think we better learn from that experience and not to do expensive
> allocation / deallocation per every surrounding text query (and for
> other proposed queries for QT4 that returns large data structures).
> In the immodules that use it (Sinhala, for example), there will be one
> per every keystroke!  I don't know how this works exactly in C++, so
> can't talk specifically.

No need to worry. In Qt we return a QString object, that only does a shallow 
copy of the data (ie. it uses reference counting).

Cheers,
Lars



More information about the immodule-qt mailing list