addResource with QUrl used in <img src> not working in MAC
-
wrote on 28 May 2020, 15:18 last edited by zandarina
Hello, I am writing a pdf report in HTML and what I do is to create the image that I want to add in the pdf and I make a unique identifier of it. Then, I use it in html to add the image. In windows it works very well. But I switched to MAC and i found an empty image.
createFiguresForPDFReport(qimage1); //create an unique identifier of the image. It is a trick //for not refering to a file. So it is not necessary to write it document.addResource(QTextDocument::ImageResource, QUrl("myimage"), qimage1); html = html + "<p><img height=150 width=450 src=\"myimage\"/></p>";
Why doesn't mac find the identifier ? I use Xcode and I don't want to use temporary image files to do that. Thank you very much.
-
Hi,
Where is that image supposed to be located ?
-
wrote on 29 May 2020, 06:40 last edited by
Thanks for answering. There is not any image file. It is created (slicing a dicom with vtk and converted to qimage. this image is created properly) and embedded in the html document and this document will be used with QPrinter to obtain a pdf. With QUrl what i get is a unique identifier and I make reference in the img tag of html. This works in windows but in mac the reference to the qimage is not considered it.
-
Thanks for answering. There is not any image file. It is created (slicing a dicom with vtk and converted to qimage. this image is created properly) and embedded in the html document and this document will be used with QPrinter to obtain a pdf. With QUrl what i get is a unique identifier and I make reference in the img tag of html. This works in windows but in mac the reference to the qimage is not considered it.
@zandarina said in addResource with QUrl used in <img src> not working in MAC:
this image is created properly
maybe, probably not.
Do you check if creation was successful ? Permissions and file directories behave slightly differently on MacOS
-
The key point here, as suggested by @J-Hilk, is: where do you create these images ? Or rather, where do you store them ?
-
wrote on 29 May 2020, 11:46 last edited by zandarina
It is not a file, it is a screenshot of the render windows and I do it with vtk and the image is fine. yes i saw the image in the render windows. I never put this image in a file. Thanks
-
Can you set that image in a QLabel and see it properly ?
-
wrote on 2 Jun 2020, 11:52 last edited by
You are right. It was not a qurl issue it was the screenshot for some reason the bounds of the render windows are not obtained with the same size. I have changed this and now i get the image.
Thank you very much
-
Glad you found out !
Since you have it working now, please mark thread as solved using the "Topic Tool" button or the three doted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)
9/9