how to insert an image in a QFile generated file using HTML
-
@ManiRon I still don't understand what exactly you're doing: first you say you want to print, now you say you want to display. Can you explain what exactly you're trying to do?
An image file is not directly part of a HTML document. A HTML document can reference images, but these images are stored in files, not in a HTML document. So, I don't know what you expect to see. -
I want to create a report in which i want to display an logo . I have opened a document using Qfile and i am writing data and creating table in that file using html so similarly i want to display the logo in that file . Ya exactly i create an HTML report and want to show or display or print a logo in that file which i am not able to do
-
@ManiRon
Like @jsulm I am still at a loss about what you are asking. I don't know what your code is about either, it opens files (for read/write at that), then doesn't use them....All you can do is if your HTML contains
<img src="Logo1.png" alt="Test" >
then there needs to be a file named
Logo1.png
in the directory where that HTML is executed from. How it gets there is irrelevant: it might be something already there, you might create it from code, I don't know, but that's what you need.QFile
is not needed, and cannot somehow be "passed" to HTML. -
@ManiRon If you don't explain how you're showing or printing your report nobody will be able to help you...
Is this "printing" you meanqData << qTextRep.document()->toHtml();
?
To display this report you can simply open the HTML document in a web browser (the picture must be in the same directory as the HTML document!). Or show it in Qt Web Engine. -
@ManiRon said in how to insert an image in a QFile generated file using HTML:
I tried but its not displaying
So, I guess by "displaying" you mean in a web browser?
Where exactly is the image file located? Is it in the same directory as the HTML file? -
@ManiRon said in how to insert an image in a QFile generated file using HTML:
Is it in the same directory as the HTML file? No
Well, then I would say this is the problem (and I already said that before: "the picture must be in the same directory as the HTML document!").
-
@ManiRon "i have to place my image at place where i am saving my html file" - yes!
How can web browser know where the picture is if the only information you give it is the file name without path:<img src="Logo1.png" alt="Test" >
?! So, where should web browser look for this picture?
"But if i give the path its not accepting at all" - how do you give it the path? Please show...