[PyQt] How to get the QRect of a QMenuBar (QPopupMenu) item ?

E

Erwan Adam

Hi all,

I try to introduce tooltips in my application written
in PyQt (more precisly, in the menubar of my application)
but I can't find a way to get the QRect instance
associated to a QMenuBar item (neither a QPopupMenu item)

I need the QRect 'cause I followed the tooltip.py file
given with pyqt to do the job with a re-implementation
of "maybeTip( self, pos )".

May be it is not the good solution ...

Help is welcome !

Cheers,

E.A.
 
K

Ken Godee

Erwan said:
Hi all,

I try to introduce tooltips in my application written
in PyQt (more precisly, in the menubar of my application)
but I can't find a way to get the QRect instance
associated to a QMenuBar item (neither a QPopupMenu item)

QObect Class?

QObject::queryList()
QObject::child()

Also try the PyQt list "pykde"
 
D

David Boddie

Erwan Adam said:
I try to introduce tooltips in my application written
in PyQt (more precisly, in the menubar of my application)
but I can't find a way to get the QRect instance
associated to a QMenuBar item (neither a QPopupMenu item)

You need to call the itemGeometry method on your QPopupMenu
object with the index of the menu item you want to examine.

Something like this should work for popup menus:

# popup is a QPopupMenu containing several items
rect = popup.itemGeometry(2) # for the third item in the menu

It may be a little more difficult to get this information out
of QMenuBar because it looks like PyQt can't access the
itemRect function when the menu bar is created by a C++
object, such as a QMainWindow.
I need the QRect 'cause I followed the tooltip.py file
given with pyqt to do the job with a re-implementation
of "maybeTip( self, pos )".

Are you trying to implement tooltips on menu items?

You may find that regulars on the PyQt/PyKDE mailing list can give
you more detailed advice:

http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Good luck!

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,292
Messages
2,571,494
Members
48,179
Latest member
รับปั๊มไลค์|LikePro

Latest Threads

Top