Can QWebView load images from Qt resource files? - qt

I've bundled some HTML and PNGs in my Qt app's resources file (for the help system). Unfortunately I can't find a way for the HTML to display images. I've tried various combinations of the QWebView's base URL, and different URLs for the <img> tag but none have worked so far.
To be clear, I want to be able to do something like this:
QString html = "<html><img href=':/resources/cat.png'/></html>";
myWebView->setHtml(html, ???);
Is this possible?

Try your resource format as:
qrc:/resources/cat.png
instead of
:/resources/cat.png
we have .css files that use images in such a format within webview and it works fine

Related

My CSS works in the inline section but not as an external stylesheet

I am currently trying to use CSS to stylize my application in Apex 5. The problem I am having is that when I write my CSS code in the "inline" section of any page in the application, then the CSS code works, but if I write the CSS code on Notepad and then upload the file and reference the file within my application, then the CSS code does not work. I have written several lines of CSS code, so I'll just post one small section of it as a sample so that you all can see my format:
body{
font: bold 12px/16px "Times New Roman";
}
I have uploaded the file in the Static Application Files section of the Shared Components page of the application. I have then tried referencing the file in different places, such as at the page level and user interface level, but nothing has worked so far. I'm very new to CSS, so any insight would be greatly appreciated. Thank you in advance!
After uploading the file have to be displayed in the list of static files. The list of files have a column Reference, which contain a string like this: #APP_IMAGES#test.css. Copy this string and put it, for example, on the page in the section CSS - File URLs. This should work.
Then make sure that file reference works. Open your page and take a look on a list of CSS files. The same functionality is present in all browsers, but it is accessible by different ways. In IE:
Press F12.
Open Network tab.
Press "Enable network traffic capturing" (a green triangle in the left top corner).
Reload the page. A list of files appears.
Find your file in a list:
If the file is not present, then you copied an incorrect link, or you copied it into an incorrect place, etc.
If the file is present, normally it should have status 200 (the Result column). If a status is not 200, there could be a lot of reasons (depending on the status).
If the file is present with the status 200, your CSS property doesn't work, because it is overridden with another CSS. To define with which one, go to the Dom Explorer tab.
You can try this approach:
On server, go to ORACHE_HOME/apex/images/css (path can be different, but you can find it by .css extension)
Put you file here
Id editor, in page properties, go to the CSS -> File URLs section
Write path like this: /i/css/new.css (i - in general, alias for your images directory)

convert a jpeg into url for css

I am new to web design and I think I need to convert a jpeg into a url. I have an image saved locally on my computer. An example website that I am using as a reference has a one page for their html/source code and a different page for their css. All of the images are listed under the css page, however, they are typed in as a url. For example url(..green sea.jpeg) When I try to replace their css code with my image, it can't be found. I know I'm new, so I figure I must be making a simple simple mistake, but everytime I try and look it up online, I find directions on how to convert a jpeg into a url and it looks like you need another kind of software to do this, but I'm not exactly sure. Any help/direction would be very much appreciated!
Thanks!
When you replace your image name for the one you see in the CSS:
url(..green sea.jpeg)
...make sure that the image you are wanting to use is in the same location (folder / place) as the green sea image.
So if I want to replace it:
url(..myNewimage.jpeg)
I would make sure it was in the same place as the image I'm replacing it with.
ALSO, I just noticed that your path is wrong. You have ".." when it should probably be "../".
So try this:
url(../green sea.jpeg)
The url you need for your code is just wherever you have posted the image on your server in relationship to the css file. For example, if your directory is structured like this:
/CSS
-style.css
/JS
/images
-green-sea.jpg
index.html
Then your url would be (../images/green-sea.jpg)

CodeIgniter + DOMPDF: Images don't appear when calling them in CSS

I started to use DOMPDF in my CodeIgniter project to render some information in PDF.
Everything is OK when I display the information in html. But... no images were displayed in PDF, for the same HTML code (info: images used for background).
Except images, the other CSS info were correctly displayed (color, text-indent,...).
I tried the same 'kind' of code without using CodeIgniter, and the images were generated correctly.
Conclusion: Problem using DOMPDF in CodeIgniter.
Some ideas? I tried many 'random' combinations, but it still doesn't work. No google results for keywords 'CodeIgniter, DOMPDF, CSS, Images'...
Thanks in advance.
After more testing, I was able to add images:
By writing the CSS inside the HTML code, using tag.
Use paths relative to the root directory, not the HTML file, like: ./assets/img/my_image.png
This worked for me, but I don't know why.

A "shortcut" method for exporting an ASP.Net Page to pdf/xls

I want to export a few Pages to pdf/xls. By Pages I mean as the eye sees it - a screenshot of the Page's contents. I know how to build pdf/xls documents using 3rd party tools but is there any way to quickly export the rendered contents of say a Panel?
edit: maybe a tool that can render the page's output as a browser would, and save it as an image file?
There is an open source console program named wkhtmltopdf which you could call from asp.net to convert the page. It can convert to PDF or an image with wkhtmltoimage (JPG, PNG, etc.) using the webkit rendering engine.
Check my answer to this question to see an example of how to convert from a html to a pdf using C#:
Easiest way of porting html table data to readable document
I can recommend http://www.screengrab.org/ for firefox.

How to use images for skins without embedding them in the external style sheet

I'm trying to create a run time css-based swf which DOES NOT have embedded images, but rather picks them up from the file system.
For example,my Current .css file has this piece of code:
.paySeatBundleAvailable {
upSkin: Embed("../images/common/pay_seat_bundle_available.gif");
overSkin: Embed("../images/common/pay_seat_bundle_available.gif");
downSkin: Embed("../images/common/pay_seat_bundle_available.gif");
}
I dont want the CSS based SWF to have all the images embedded as I have a lot of images. Rather I want the images to be loaded at runtime from the path specified.
I tried using 'Url' in place of 'Embed' , but it throws 'error #1034 type coercion' error.
Help Please!! What is the correct approach?
Create a general skin that does all states (up, over, down, etc) which only has one Image Object. Set the source of that Image object to the appropriate strings and the Image will then do an http call to that image automatically without embedding anything.

Resources