[Qt-interest] Setting the Window Icon
O'carroll, David T
david.t.o'carroll at intel.com
Wed Feb 16 10:51:05 CET 2011
Hi,
Thanks for the reply.
I tried checking if the file existed using the QFileInfo class and it always found the file.
I also used QDir to list the contents of the directory in which all the images I need are stored and it was able to find them all.
This is the code I'm using to check for the file:
QFileInfo file("/path/to/file.png");
if(file.exists())
{
qDebug() << "Setting window icon";
QApplication::setWindowIcon(QIcon("/path/to/file.png"));
}
else
{
qDebug() << "File: " << file.absoluteFilePath() << " not found";
}
This will always output "Setting window icon" and yet the icon is not always set (in fact it is quite rare that it does get set).
Seeing as the file can be read by both QFileInfo and QDir could there be a problem with QIcon?
Dave
From: qt-interest-bounces+david.t.o'carroll=intel.com at qt.nokia.com [mailto:qt-interest-bounces+david.t.o'carroll=intel.com at qt.nokia.com] On Behalf Of Malyushytsky, Alex
Sent: Tuesday, February 15, 2011 11:35 PM
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Setting the Window Icon
My guesses this is failure to find image file.
Try to use absolute path instead of relative and check if file exists.
Put some code which will notify you about path when does not.
Alex
From: qt-interest-bounces+alex=wai.com at qt.nokia.com [mailto:qt-interest-bounces+alex=wai.com at qt.nokia.com] On Behalf Of O'carroll, David T
Sent: Tuesday, February 15, 2011 6:10 AM
To: qt-interest at qt.nokia.com
Subject: [Qt-interest] Setting the Window Icon
Hi,
I am trying to integrate a demo into the Meego IVI UX. I am trying to set the window icon of an application to a different image depending on what QWidget is running. The QWidget is launched as the application starts and is passed to the application as an argument (so it only needs to be set once). Currently I am setting it in main.cpp with:
QApplication::setWindowIcon(QIcon("/path/to/image.png"));
However, this leads to somewhat random results wherein the image is set sometimes and not others. Is there something I'm missing about QIcon (I'm used to working with QPixmap) or am I simply going about this the wrong?
Regards,
Dave
--------------------------------------------------------------
Intel Shannon Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263
Business address: Dromore House, East Park, Shannon, Co. Clare
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
--------------------------------------------------------------
Intel Shannon Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263
Business address: Dromore House, East Park, Shannon, Co. Clare
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110216/93b454ef/attachment.html
More information about the Qt-interest-old
mailing list