I have svg image with this attributes: viewBox="0 0 100 100"
This is basic code which I use for displaying svg:
Image{
width: 50
height: 50
source: "test.svg"
}
and it's not ok because image is rasterized before resizing to width and height values(50,50).
This code works perfect on all resolution:
Image{
width: 50
height: 50
sourceSize.width: width
sourceSize.height: height
source: "test.svg"
}
because image is drawn in exact dimensions which is needed!
Is it possible to get same functionality in a TextEdit where <img> tag is used?
<img src="test.svg" width="50" height="50">
This code doesn't work because sourceSize can't be set... and image is rasterized before resizing and displaying...
Maybe there is some other way to accomplish this?
The only solution is to provide the image size as part of the image url, and reimplement QTextDocument::loadResource or QTextEdit::loadResource in a derived class. Your image element would then look like:
<img src="test.svg?50x50" width="50" height="50" />
You can parse the url in your implementation of loadResource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With