drawText in QQuickItem
-
Hey guys,
I'm writing a QQuickItem to display a ruler.
So I have several lines and some text.
I have no problem to draw the lines but I don't see a good way to draw my text next to it.As it seems that there is no textGeometry I would like to instantiate qml-Textelements from c++.
In what class do I find the qml-textelements?CU
mts -
Yes it does but you wont need to do it manually as the paint() will do it internally. I don't know how GPU intensive your application is but I had been using it for some of my projects which included animations and it worked fine without any noticeable performance drop.
-
If using QQuickPaintedItem it's better to use paint() rather than updatePaintNode().
AFAIK there's no way to use QPainter in updatePaintNode(). -
@p3c0 i tried using QQuickPaintedItem and use QPainter to draw text, however seems like there's a problem when rendering the text, it appears to be pixelated or blurred in iOS (retina deisplay) devices while on Android, everything is perfect. Read somewhere that antialiasing isn't working on QQuickPaintedItem. Do you know any workaround on this? TIA.
-
@literA2 Seems like a bug. Check QTBUG-40489. It still unresolved. But there is a patch provided.
-
Thanks @p3c0
Based on the documentation, QtDeclarative has already been deprecated in favor of the two new classes: Qt Quick and Qt QML. QQuickPaintedItem can be use as convenient way to port QDeclarativeItem-based classes that use the QPainter API.
I've been searching on the internet how to render text on QSG nodes but to no avail. I'm still stuck into this problem. :(