Customize QMenu display with QProxyStyle
John Sturtz
john at sturtz.org
Mon Jun 9 05:14:15 BST 2025
Hello again PyQt sages. Hoping for some insight here -- despite a few
hours' time fiddling with this, I don't seem to even be getting past
square one.
I'm trying to modify display of items in a QMenu using QProxyStyle.
Basically, I've defined a class named Style that derives from
QProxyStyle, and re-implements drawItemText() (which, just for starters,
tries to right-justify the menu item text).
I create a QMenu object, create an object of the Style class, and call
.setStyle() to set it as the menu's style.
It may or may not be the case that my drawItemText() implementation
successfully right-justifies the text. I'll never know, because it
never gets called. What (probably really basic thing) am I missing?
Thanks! [short sample code attached]
/John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20250609/d93dee1b/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: text/x-python
Size: 1403 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20250609/d93dee1b/attachment.py>
More information about the PyQt
mailing list