PDA

View Full Version : represent svg in tab view



Dilshad
26th July 2010, 13:30
Hello all,
I have an svg file which has a lot of graphs representing different values.
Is it possible to represent each graph separately in tab view?
Thanking you in advance

Lykurg
26th July 2010, 14:38
Theoretically yes, but as far as I know QtSVG has no option to only show one "graph" identified by an id. But you can do a workaround by loading your svg with QDomDocument and strip the non needed graphs out and then display it.

ChrisW67
26th July 2010, 22:54
The SVG support does have a way to show part of a single SVG image by ID:

void QSvgRenderer::render ( QPainter * painter, const QString & elementId, const QRectF & bounds = QRectF() )

I have used this in anger to render user-selected parts of form templates. You have to be a little careful of the limits to Qt SVG support though (SVG Tiny) with wrapped text elements for example.

Lykurg
26th July 2010, 23:11
The SVG support does have a way to show part of a single SVG image by ID:Great, I wasn't aware of that.

Dilshad
27th July 2010, 06:27
Thank you ChrisW67,
I am new to Qt and do not know much about it. If my understanding is correct, then I will have to convert the image formed in the painter into a widget to represent it in the tab widget. Or will it be represented directly?

ChrisW67
27th July 2010, 09:47
You will have to paint the SVG sub-set into a widget that is displayed on a tab. You can render() using any Qt QPainter so there is more than one way to do it (oops slipped into Perl mode there). You might like to put a QLabel on each tab, render into a QPixmap (by creating a QPainter with the pixmap as the paint device), and then call QLabel::setPixmap().