Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Ampersand (&) works strange way in Menu/Action title in Qt 6.x
Forum Updated to NodeBB v4.3 + New Features

Ampersand (&) works strange way in Menu/Action title in Qt 6.x

Scheduled Pinned Locked Moved Solved Qt for Python
3 Posts 2 Posters 796 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    StarterKit
    wrote on last edited by StarterKit
    #1

    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:
    one
    two
    three

    JonBJ 1 Reply Last reply
    0
    • S StarterKit

      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:
      one
      two
      three

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @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-94481

      and the latter states:

      Fix Version/s:

      6.3.0 Alpha

      This is your issue?

      S 1 Reply Last reply
      1
      • JonBJ JonB

        @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-94481

        and the latter states:

        Fix Version/s:

        6.3.0 Alpha

        This is your issue?

        S Offline
        S Offline
        StarterKit
        wrote on last edited by
        #3

        Hi @JonB,
        Thanks, it looks exactly like my problem. Thanks for the reference.

        1 Reply Last reply
        0
        • JonBJ JonB referenced this topic on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved