Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8820337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:35:03+00:00 2026-06-14T05:35:03+00:00

I am trying to get create a QIcon object from a website’s favicon.ico file.

  • 0

I am trying to get create a QIcon object from a website’s favicon.ico file. Since this download doesn’t necessarily happen on the GUI thread, I cannot use QPixmap, and so far I have had no luck figuring out how to convert from QImage to QIcon without using QPixmap, so I can’t use something like QImageReader.

I have gotten the following code to work:

QUrl url("http://www.google.com/favicon.ico");
QNetworkRequest request(url);

QNetworkReply* pReply = manager.get(request);

// ... code to wait for the reply ...

QByteArray bytes(pReply->readAll());

QFile file("C:/favicon.ico");
file.open(QIODevice::WriteOnly);
file.write(bytes);
file.close();

QIcon icon("C:/favicon.ico");
return icon;

However, I want to avoid writing a temporary file. So I tried something like…

QBuffer buffer(&bytes);
buffer.open(QIODevice::ReadOnly);
QDataStream ds(&buffer);

QIcon icon;
ds >> icon;

But that doesn’t work.

Does anyone have any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:35:04+00:00Added an answer on June 14, 2026 at 5:35 am

    QDataStream doesn’t work because it’s expecting a PNG image from the stream.

    I wouldn’t use the temp file approach either since it may still construct a QPixmap under the hood. In fact, QIcon is not guaranteed to be thread-safe and the use in non-GUI thread should be avoided.

    I would just keep the byte array as is and pass it back to the GUI thread. Convert it into a QPixmap then a QIcon when you need to show it. It’s not really so heavy a computation anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to create a silverlight wepart to get the listItems from a SharePointList.
I am trying to create a searchable activity however when I get to this
I am trying to get the bitmapdata from a MovieClip and create a Sprite
I'm having problems trying to get a query like this table answers CREATE TABLE
I am trying to get some values from a List and then create a
I'm trying to get parameter from MYSQL procedure. My proc: CREATE PROCEDURE proc(someIn INT
I'm trying to get data from the database in order to create a list
I am trying to get some fields from the following database: CREATE TABLE `messages`
I am trying to get the data from the webservice and create dynamic custom
I am currently trying to get my server to create a connection with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.