[PyKDE] Icon with text in QMenuBar
Hans-Peter Jansen
hpj at urpla.net
Mon Jun 6 20:47:47 BST 2005
Am Montag, 6. Juni 2005 20:37 schrieb Peter Clark:
> 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?
Typically, this is the right moment to grok the concept of QActions..
Good luck,
Pete
More information about the PyQt
mailing list