Solved Ampersand (&) works strange way in Menu/Action title in Qt 6.x
-
Hi!
I'm not sure is it python related or not but I have it only on python and only after upgrade from Qt 5.15 to Qt 6.2.
I use ampersand (&) in menu titles and everything worked fine as expected. I.e. ampersand made a shortcut out of next symbol.
But with Qt 6.2 it somehow adds ellipsis in the middle of title - better to see it on screenshot creabed by example code below.
Is it some strange bug or I don't know something about Qt 6.2? (there was no such effect with Qt5.x)Here is a code snippet (There is no example without ampersand because it works fine without it - the same way as with "Menu" example):
from PySide6.QtWidgets import QApplication, QMainWindow from PySide6.QtGui import QAction class MyWindow(QMainWindow): def __init__(self, *args): QMainWindow.__init__(self, *args) self.menu = self.menuBar() sub_menu1 = self.menu.addMenu("&Action 1") self.action1 = QAction("Show &Effects...") sub_menu1.addAction(self.action1) sub_menu2 = self.menu.addMenu("&Action 2") self.action2 = QAction("&Show Effects...") sub_menu2.addAction(self.action2) sub_menu3 = self.menu.addMenu("&Menu") sub_menu3.addMenu("&Show Effects...") app = QApplication([]) win = MyWindow() win.show() app.exec()
Here is a result:
-
@StarterKit
I can't find a reference at present, but I think there is a Qt 6.x bug to this effect. Discussed in other thread(s) on this forum and a Qt bug raised. But I have no proof for this, yet :)UPDATE
https://forum.qt.io/topic/130819/menu-item-with-mnemonic-gets-cut-off
https://bugreports.qt.io/browse/QTBUG-94481and the latter states:
Fix Version/s:
6.3.0 Alpha
This is your issue?
-
Hi @JonB,
Thanks, it looks exactly like my problem. Thanks for the reference. -