Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84103

QML AbstractButton.text requires extra ampersand escaping &&&

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.14.2
    • Quick: Controls 2
    • None
    • All

    Description

      QtQuick.Controls 2 glitches on buttons with &-shortcuts in text. To be precise, it parses ampersands more than once. Consider an showcase below:

      import QtQuick.Controls 2.12 as QQC2
      import QtQuick.Layouts 1.14 as L
      
      L.ColumnLayout {
          // OK: Label does not parse for ampersands
          QQC2.Label  { text: "Rock & Roll" }
      
          // Err: amp is not shown, space is a shortcut
          QQC2.Button { text: "Rock && Roll" }
      
          // OK: Looks like on a label
          QQC2.Button { text: "Rock &&& Roll" }
      
          // OK: R is shortcut
          QQC2.Button { text: "Rock &&& &&Roll" }
      }
      

      Documentation for QtWidget's QAbstractButton::text counterpart defines the rules for ampersand parsing: use double-ampersand to insert a one literal ampersand.

      Documentation for QML AbstractButton.text counterpart does not mention ampersands at all, but parses them triple per one.

      Attachments

        1. screenshot-1.png
          5 kB
          ivan tkachenko
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            ratijas ivan tkachenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes