I used to make Ajax requests to read files from a server. But now, I would like Qt to read a file from the local disk and send its content to my web app. I think I need Qt to catch Ajax requests from the web app and return the file content as the Ajax request result. The problem is I don't know how to do. Use the load HTMLString(: base URL:) method to begin loading local HTML files or the load(:) method to begin loading web content. Use the stop Loading method to stop loading, and the is Loading property to find out if a web view is in the process of loading.
I am trying to load and show some local urls with QWebEngineView which are based on QtHelp in my application, but it is not possible. I have just managed to load either the HTML code or the text inside it thanks to a QHelpEnginem, but it is not possible to load the images, and the linking inside it does not work either. The urls could be previously displayed with QTextBrowser, but since I want to add some more advanced functionality to the html I would like to change to the QWebEngineView.Does anybody know how to do this, or if it is possible at all? Is it necessary to modify the base url?
SetHtml ( html )The setHtml method can take an optional second argument, the base URL of the document - the URL based on which any relative links contained in the document are resolved. Other QWebView Content TypesA QWebView's content does not have to be HTML; if you have other browser-viewable content, you can put it in a QWebView using its setContent method, which accepts the content and optionally its MIME type and a base URL. If the MIME type is omitted, it will be assumed that it is text/html; no autodetection of MIME types has been implemented yet, though it is at least tentatively planned. I've not managed to find a list of MIME types that can be handled by the QWebView, but here is an example that works with a PNG file.