Solved how to insert an image in a QFile generated file using 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. -
@jsulm actually i might have to print some data also thats why i am asking, may be i will show my report how it looks
-
@ManiRon The code you posted does not print anything (except HTML text to the console), so I'm not sure what your question currently is...
Just to be sure: by "printing" you mean print on a printer? -
This post is deleted! -
@jsulm No sir, I will generate a html file with that code but in that html code i want to place or display an image . I tried but its not displaying
-
@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? -
@jsulm yes
-
@ManiRon I asked 3 questions. To which question does "yes" belong?
-
So, I guess by "displaying" you mean in a web browser? yes
Where exactly is the image file located? from where i am running my application
Is it in the same directory as the HTML file? No -
@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!").
-
@jsulm if i simply give this <img src="Logo1.png" alt="Test" > i have to place my image at place where i am saving my html file . But if i give the path its not accepting at all(means its not showing the image at all)
-
@jsulm
QString Header = "<img src="D:/APP/Image" alt="Test" >";Like this if i mention its not displaying the image
-
@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... -
This post is deleted! -
-
@ManiRon Why don't you put the image into same directory as your HTML document or into a subdirectory there? I don't see the point to spread HTML and images over completely different locations as they belong together to build a HTML page.
See https://www.w3schools.com/html/html_filepaths.asp for possibilities HTML provides.
The syntax you're using is invalid. -
@jsulm Thank you sir , I have been giving the path wrongly , It worked below is the code i used