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

Murat ŞEKER m.seker at aol.com
Sat Oct 23 22:02:32 CEST 2021


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 ? 

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
}

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



 


More information about the Development mailing list