[PyKDE] Icon with text in QMenuBar

Hans-Peter Jansen hpj at urpla.net
Tue Jun 7 16:06:38 BST 2005


Am Dienstag, 7. Juni 2005 15:16 schrieb Peter Clark:
> On Monday 06 June 2005 23:47, Hans-Peter Jansen wrote:
> > 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..
>
>     Thanks for the hint, but I'm afraid that I'm still a little ways
> from groking QAction. Reading The Fine Documentation, I understand
> fine how it works for menu *items*. But the menu bar continues to
> thwart my every attempt. It looks as though for an item to be in the
> menu bar, it must be a QPopupMenu. Could you point me in a more
> specific direction? Thanks,

Oops, I did misread your problem - sorry. I really don't have any idea, 
how to get a pixmap and text item into the menu bar, and I cannot 
remember any Qt app doing so. Scribus shows small icons in there, when 
a document is maximized.

I have to pass that question back to the audience listening..

Peter, let me know, if you succeed.

Pete




More information about the PyQt mailing list