Is it possible to transform SVG files with QT programmatically? Or is it better to programmatically rederize each image using shapes and lines with QPainter?
-
I'm developing a proof of concept for an app that presents information in the form of graphs, each node may have more than one connection.
I intend to use SVG to build reference images, but I need each image to have the possibility of being altered to add connection points or even change its characteristics according to parameters.
For example, I have a shape with 2 connection points, by default, but a new point was added, now it has 3 points, so I would pass a parameter to the control class that would add the extra point and do the resizing calculations for the SVG structure and would render again.
Is it possible and is there any example for such programming with SVG?
Or is it better to programmatically rederize each image using shapes and lines with QPainter?
-
@JoeCFD, I used this example to build the base of my graph manager, now I need to dynamically build each node, facilitating the addition of new simple nodes, of course more complex ones like this one that may have the number of pins will require a special strategy , but for instances like a FlipFlop that have fixed input and output ports, it won't be a problem to just add a new SVG file, but for us that allow you to add ports almost infinitely, like an AND/OR/NOR port, these required a certain expansion logic.
-
@Carlos-Delfino "Is it possible to transform SVG files with QT programmatically?"
SVG is just XML, so you can read and do whatever you like to the XML using the generic XML classes in Qt.
Depending on the transform, you may be be able to use XSLT with the (deprecated) Xml Patterns module or a third-party library. So, if your "template" AND-gate SVG has identifiable points to insert input nodes and sizes (does SVG support a scaled sub-block?) for the gate symbol then it should be doable.Neither of these is going to dynamically change the displayed form of the SVG, or change any on-screen interaction (e.g. drag-n-drop to connect to the dynamically created points). As @JoeCFD suggests, QGraphicsView might be a better fit.