[Development] Why clipping is enabled by default in QQuickTextField ?

Murat ŞEKER m.seker at aol.com
Tue Oct 26 02:20:37 CEST 2021


Hi Shawn,

Thanks for the response. I'll be keeping an eye on the bug report.

Br.
Murat


-----Original Message-----
From: Shawn Rutledge <Shawn.Rutledge at qt.io>
To: Murat ŞEKER <m.seker at aol.com>
Cc: development at qt-project.org <development at qt-project.org>
Sent: Mon, Oct 25, 2021 9:36 am
Subject: Re: [Development] Why clipping is enabled by default in QQuickTextField	?


I saw your comment on IRC a while after you had written it and left; see https://bugreports.qt.io/browse/QTBUG-97648

> On 2021 Oct 23, at 22:02, Murat ŞEKER via Development <development at qt-project.org> wrote:
> 
> Hello,
> 
> We are investigating some performance issues and it turns out the clipping in TextField ruins the batching and results in ridiculous number of batch counts (We have significant number of text fields in the scene.).
> 
> https://code.woboq.org/qt5/qtquickcontrols2/src/quicktemplates2/qquicktextfield.cpp.html#911
> 
> What is the rationale for not leaving the clipping decision to user here ? 

I think because if it doesn’t clip and you type too much text, it would go outside the frame.

The question is, if we change TextInput to avoid rendering any glyphs outside its own bounds, will anybody consider that to be a loss of functionality?

I haven’t tried to do that yet; it’s just an idea.
> 
> Maybe it should be mentioned in documentation so that people don't have to dig the source code when they encounter performance issues with TextFields ?
> 
> There is TextInput which TextField derives from and it doesn't enable clipping by default so we are planning to use it as follows instead of TextField :
> 
> TextInput {
>    clip: contentWidth > width
> }

Maybe we should do (the equivalent of) that; I haven’t tried that either.


> That way we can at least gain some performance from the items that contain text shorter than the input box. However TextInput lacks some functionality like placeholder/decorators and we will need to implement those ourselves which is not convenient.
> 
> My real questions is: I need clipping for sure but it costs a lot. Is there any way to avoid clip: true and still prevent TextInput/TextField/(any kind of text input) drawing beyond the boundaries of their bounding rectangles ?
> 
> At some point I found myself considering a global clipper item which knows the location/bounding box of each text input and use that information as a mask (shader effect) for all inputs in a single layer so that input items can still be batched. But that's crazy. I don't want to introduce such a thing in our codebase :)
> 
> Any better suggestions or am I stuck with TextInput and clip: contentWidth > width ?
> 
> Thanks for the great work.
> 
> Br.
> Murat Seker

> 
> 
> 
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development





More information about the Development mailing list