Results 1 to 5 of 5

Thread: get favicon of website

  1. #1
    Join Date
    Jan 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default get favicon of website

    how i can get a favicon of website
    i try
    Qt Code:
    1. QWebPage m_page;
    2. QIcon icon = m_page.mainFrame()->icon();
    3. // and
    4. m_page.settings()->iconForUrl(url);
    To copy to clipboard, switch view to plain text mode 
    even if favicon in html tag
    Qt Code:
    1. //get favicon
    2. QWebElement document = m_page.mainFrame()->documentElement();
    3. QString icon_url = "";
    4. QWebElementCollection collection = document.findAll("link");
    5. foreach(QWebElement current_element, collection){
    6. if(current_element.hasAttribute("rel") && current_element.attribute("rel") == "icon"){
    7. qDebug()<<current_element.attribute("href");
    8. icon_url = current_element.attribute("href");
    9. }
    10. }
    11. Qicon icon = m_page.settings()->iconForUrl(url+ icon_url);
    To copy to clipboard, switch view to plain text mode 
    but it always a default icon

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: get favicon of website

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: get favicon of website

    no under linux kubuntu 11.04 qt 4.7

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: get favicon of website

    Qt Code:
    1. Qicon icon = m_page.settings()->iconForUrl(url+ icon_url);
    To copy to clipboard, switch view to plain text mode 
    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jan 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: get favicon of website

    yes for example i try http://novafilm.tv/ (for test) <link type="image/x-icon" rel="icon" href="/static/i/favicon.ico">

Similar Threads

  1. Create a Website
    By Trader in forum Newbie
    Replies: 8
    Last Post: 10th July 2012, 07:27
  2. Puzzle Example on Qt's website
    By yakuzan in forum Newbie
    Replies: 1
    Last Post: 27th May 2010, 05:43
  3. Can QWebPage see changes in a website
    By probine in forum Qt Programming
    Replies: 3
    Last Post: 15th August 2009, 23:23
  4. Replies: 0
    Last Post: 3rd June 2009, 04:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.