QWebEngine vs QGraphicsScene/QGraphicsSvgItem
-
I'm looking to create a live schematic with data that updates at a 10hz rate, up to 100 sensors changing values along with some animations for pipe flow, valves, etc. It'll be a standalone app developed in PyQt
I'm a little bit unsure as to which of the above makes the most sense. After some quick playing I seem to have the following thoughts, some of which may be wrong, so please correct.
QWebEngine seems simple out of the gate. Javascript to manipulate the dom seems pretty straight forward. What I'm a bit unsure of is things such as zoom and panning the image without the scroll bars. I'm not really seeing how a viewport/scene works as it does below in the QGraphicsSvgItem.
QGraphicsSvgItem seems my preferred. My only big question has to do with manipulating the DOM for updates. The only way I've been able to do it is to keep the DOM local, manipulate it, then do a renderer().load() of the entire svg string each time. This seems extremely resource intensive and worry about performance doing it 10 times a second. Am I over worrying about this and the renderer is expecting and handles this in an optimized way? I also wonder if this is going to mess up when I start adding animations as each time the svg is loaded it'll basically restart?
Or is there another approach that is better fitting that I'm missing?
-
Hi and welcome to devnet,
Do you already have the animation related stuff ?
Otherwise a pure QGraphicsView with items could fit the bill or even Qt Quick which is made for animation.
-
For the most part. I take a vizio of the schematic, save it to svg and then do some mark ups in inkscape such as add a text label to for sensor values and animations for pipe flow. Using qwebengine makes it really easy to change data, its just javascript calls to change the DOM, using qgraphicssvgitem and scenes make it easy to zoom, move around, and seems to be a bit more of a custom application solution, but I worry about resetting animations mid update being forced to do an entire load into the renderer.
I could do it all as standard 2d graphics in a painter, but I'm really interested in playing with an svg based solution if possible.
-
From your description, I would say webengine is likely your best bet.