PDA

View Full Version : get favicon of website



pussbb
6th May 2011, 08:15
how i can get a favicon of website
i try


QWebPage m_page;
QIcon icon = m_page.mainFrame()->icon();
// and
m_page.settings()->iconForUrl(url);

even if favicon in html tag


//get favicon
QWebElement document = m_page.mainFrame()->documentElement();
QString icon_url = "";
QWebElementCollection collection = document.findAll("link");
foreach(QWebElement current_element, collection){
if(current_element.hasAttribute("rel") && current_element.attribute("rel") == "icon"){
qDebug()<<current_element.attribute("href");
icon_url = current_element.attribute("href");
}
}
Qicon icon = m_page.settings()->iconForUrl(url+ icon_url);

but it always a default icon

high_flyer
20th May 2011, 10:58
If this is under windows:

Note: Web site icons, also known as "FavIcons", are currently not supported on Windows. We plan to address this in a future release.

pussbb
25th May 2011, 11:11
no under linux kubuntu 11.04 qt 4.7

high_flyer
25th May 2011, 11:24
Qicon icon = m_page.settings()->iconForUrl(url+ icon_url);
is the icon you get a valid icon?
Are you sure the site implements a special icon?

Returns the web site's icon for url.

If the web site does not specify an icon OR if the icon is not in the database, a null QIcon is returned.

pussbb
26th May 2011, 14:12
yes for example i try http://novafilm.tv/ (for test) <link type="image/x-icon" rel="icon" href="/static/i/favicon.ico">