[PyQt] Setting the window icon of a QDialog or QWidget using setWindowIcon() method

Hans-Peter Jansen hpj at urpla.net
Mon Dec 13 22:50:08 GMT 2010


On Monday 13 December 2010, 19:06:49 Guruprasad wrote:
> Hi all,
> I am a PyQt4 beginner just in the process of learning.

Welcome to the club.

> I came across 
> this method setWindowIcon() that is used to set the icon of a
> window/dialog/widget. But calling that method before calling the
> show() method doesn't set the icon, but calling it after a call to
> the show() method, sets it properly. 

I assume, you mean show() on the top level window.

> Is there any explanation for 
> this behaviour.

In Qt, most things (related to drawing at least) happen asynchronous 
(e.g paint events in the event loop). On top of that, setting the 
window icon is finally done by the window manager, hence even more 
asynchronicity. 

What you observe is usual behavior, which might change if  window 
managers or operating systems change.

> I am using PyQt4 version available on Ubuntu 10.04 and use Gnome
> desktop environment.

Pete


More information about the PyQt mailing list