Vote count:
0
I'm writing a Python and PyQt5 program for people who prefer to use the keyboard rather than the mouse (e.g. Emacs users). I think it would be useful for some buttons to display the key shortcut that executes their action, like this:
One way to achieve this seems to be to subclass QPushButton, override its paintEvent method, use QPushButton's painting and then draw over it with QPainter.drawRoundedRect and QPainter.drawText. However, I'm new to Qt and have some questions:
- Is this the best way?
- To create a "professional" widget, what other methods should I override?
sizeHint,minimumSizeHint, some others? - How to draw a
QPushButtonwith its text and icon off-center, so that when I paint the key shortcut over it, it'll be the right size and centered?
asked 16 secs ago
How to create a button with a key shortcut label on it?
Aucun commentaire:
Enregistrer un commentaire