Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
how to handle millions of items ?
i am using QGraphicsView and QGraphicsScene to display millions of items, but it's very slow.
is there any way to improve the GUI speed with this framework ?
I can see many commercial tools can handle even billion of items, how to achieve this ?
Hi and welcome to devnet,
The usual technique is: render only what make sense to show.
There's no use trying to render each feather of a Kiwi bird if you are looking at it from the top of a building.
The same goes the other way around, there's no use rendering the full building since you're on top of it trying to look at a Kiwi bird.
This post is deleted!
or is there any example ?
@aha_1980 thanks, I tried this example before, when I increase the number to 4 millions, it's also very slow . it doesn't help too much.
Have you thought that each element needs memory too? Holding 4 million objects in memory may be challenging.
If you really need so many items, you will need to invest some more energy.
@aha_1980 yes, actually i have more than 4 millions of objects (polygon shapes) that could be 100000000. i want to show a blurred picture unless zoom in.
i see many EDA tools, like synopsys, cadence, they can show billions of polygon shapes.
they can show billions of polygon shapes
I doubt that. It is simply not possible to see so many objects on a display (a display does not even has so many pixels...). I'm quite sure they reduce the amount of objects to what actually makes sense.
student last edited by student
@jsulm yes, agree with you. i believe they must have some mechanisms to process this.
you know, we just want to see detail when zoom in to a specific level, otherwise, just show a rough picture. that's why I asked this question here to see if anyone have experience on such case. in the other world, how to process large amount of polygon shapes by using Qt.
i am a new to Qt :-)
@SGaist thanks for your reply, i am a newer to Qt.
yes, I don't want to show them at full pic view, so I just show them when zoom in to a specific value, in the paint function for each item, I use :
option->levelOfDetailFromTransform(painter->worldTransform()) < SpecificValue: return
but it doesn't help much.
Could you help to describe more about how to filter them ? or is there any example ?
thanks very much !
Before going further, what kind of rendering are you looking at ? Just to ensure you are choosing the right tool for your task.
@SGaist I have many polygon shapes, and need to view / edit them, for view/edit, i think just when zoom in, without zoom in, a rough picture is enough.
as you said: """ There's no use trying to render each feather of a Kiwi bird if you are looking at it from the top of a building.
The same goes the other way around, there's no use rendering the full building since you're on top of it trying to look at a Kiwi bird."""
Is it a 3D scene ?
@SGaist no, just 2D polygons.
any new idea?
kenchan last edited by kenchan
are these polygon shapes single polygons or meshes of polygons?
Are they overlapping i.e. can be hidden behind or hide others?
Do they have some measure of coherence you can exploit?
These are the kind of questions you should be asking yourself so you can determine the best strategies for LOD.
The obvious strategies are minimum pixel coverage, removing items completely hidden items, removing items outside the viewport.
If you really want to do it brute force use the GPU directly via OpenGL calls to do the drawing and don't rely on the Qt graphics items at all. Even then you might need to use some clever LOD strategies with that many polygons.
fcarney last edited by
@kenchan Thanks. they are single polygons, some of them may overlapping each other.
yes, I agree I need to minimum the piexl coverage, that means filter out the ones need to render.
the question is how to filter them out according to view port with so many polygons quickly.
when zoom to an area, it should respond quickly, when fit the view, also quickly.
I don't think it's a special case just for me. this should be a general case in many applications.
So i want to see if there is existing framework which can handle such case.
As suggested you should research LOD algorithms. For example this may be of some use or maybe a clustering algorithm. You may also benefit from a space partitioning scheme that's not the one implemented by the graphics scene, but something custom. In any case such problems are not trivial.