[PyKDE] Icon with text in QMenuBar

Peter Clark mla-pykde at forrussia.org
Mon Jun 6 19:37:56 BST 2005


    I've been playing around with menus (I just discovered that it's possible 
to embed widgets in a menu--neat!) and now I'm wondering about icons. Is it 
possible to combine text in a menu bar with an icon?
    I tried playing around with menu.py from the PyKDE examples. Here's the 
snippet I was playing with (lines 169-170):

self.menu = QMenuBar( self )
self.menu.insertItem( "&File", self.file )

I was able to substitute an icon for text with:

self.menu.insertItem( QPixmap ( p1_xpm ), self.file )

Where p1 is an xpm of a yellow folder (defined in the code). To place an icon 
and text together, I tried this:

self.menu.insertItem( self.p1, "&File", self.file )

No errors, but likewise no icon next to "File". Any suggestions?
    :Peter




More information about the PyQt mailing list