Solved QGraphicsView and QGraphicsScene drawing 10 000 QGraphicsSimpleTextItem is very slow
-
Hi,
I am using Qt for a while, so I am drawing 10 000 QGrapicsSimpleTextItem in QGraphicsView with QGraphicsScene.
And I implemented a zoom in and zoom out with the function scale(), I use QGraphicsView::ScrollHandDrag to drag the scene.The problem is when I fitInView the view becomes slow to zooming and draging.
Note:
- I tried caching all possiblities.
- I am using QOpenGLWidget.
- drawing 10 000 QGraphicsLineItem has no effect on performance instead of QGrapicsSimpleTextItem.
Is there a way to customize the performances of drawing the text items in Qt.
Thank you in advance.
-
@Tarik-EL-JABIRI
Well, 10,000 items is a lot for the framework to look through to fit! Do you really need that many items, I'm not sure the user can even see them all? -
@Tarik-EL-JABIRI I guess you need to re-think the user experience, and as @JonB mentioned think about displaying all those items at once.
As a user I cannot imagine looking at 10K items on a laptop display; maybe your use case asks for dual 50 inch monitors I don't know.
I guess I'd approach this issue trying to use like a region of the screen, given the current zoom level, and with that constrain find and draw only the items inside the region. -
@JonB
Thanks for your response.
I need them all, because my app will work with large topographic plans with a lot of Items (Texts, lines, ploylines, ....) .
and that is not friendly with performances in Qt;I don't know how to customize this.
AutoCAD is doing very well with large scenes like this.
-
Hi,
Did you already looked at the 40000 Chips example ?
It might contain some interesting stuff for you use case.
Hope it helps
-
@SGaist
Thank you for your response.
Yes i have seen this example but is not drawing text the problem is with the text items not with lines or rectangles or polylines the problem is all about rendering text a lot of text items. -
Are these all different texts ?
-
@SGaist
Hi,Not all of them there are some of are the same and others different.
But Qt is ok with 10k lines but text is a problem for it.
I dont how Qt render text but when i remove text items it works fine and fast. But I need text in my drawing. -
What it if you generate images out of the text (just for testing) ?
-
@SGaist
Hi,
I don't know but the text might be edited.
So thank you everyone.
I want to close this topic.