[SOLVED]check if url is an image
is there any way to check, using the webview, if the loaded page is an image or not?.. for example if i open this link "image from google-search-image":http://phfg.fulcri.it/getImageBdf.asp?idArticolo=1841986&tipo=4&larghezza=200&altezza=200&key=2f5e1bd528f15f9899e1cf039cbe2d09 how can i check if it is an image?
i don't know if there is a feature for QWebView, but if you use QNetworkRequest for the given URL and then check the header data of the reply you will get the information, e.g:
@void downloadFile(QUrl url)
// Start request using a QNetworkAccessManager
// Receiving function using:
// connect(mpDownloadManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slot_fileDownloadFinished(QNetworkReply*)));
void slot_fileDownloadFinished(QNetworkReply* pReply)
QString sFiletype = reply->header(QNetworkRequest::ContentTypeHeader).toString()
sFiletype will contain something like:
Hope that might help you.
i try your solution but for the link "image":http://phfg.fulcri.it/getImageBdf.asp?idArticolo=1841986&tipo=4&larghezza=200&altezza=200&key=2f5e1bd528f15f9899e1cf039cbe2d09, the file type "is text/html; charset=us-ascii" instead of "image/jpeg"
I will check the code when i'm at home again....
But using firefox you can check the header information on your own.
Just open the url containing the image file in firefox. Then open tools->web developer->web console and press F5 to reload the page.
Under 'network traffic' you will see a 'get' command:
You can inspect the 'request' and the 'response' data at this point by clicking on the entry.
i try again your example, now it works, i don't know what is changed.. sorry