Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Quick Controls 2: IconLabel fails to display "&" symbol.
Forum Updated to NodeBB v4.3 + New Features

Quick Controls 2: IconLabel fails to display "&" symbol.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 4 Posters 1.8k Views 2 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.
  • E Offline
    E Offline
    EStudley
    wrote on last edited by
    #1

    Hey all,

    I've made my own Style for my project. It has a simple Button implementation with an IconLabel as the contentItem.

    When I set my Button's text to "This & That" it displays "This _That". This seems to be the default behavior or IconLabel, even outside the button implementation. Am I doing anything wrong or is this just a bug?

    import QtQuick 2.10
    import QtQuick.Controls 2.3
    import QtQuick.Controls.impl 2.3
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
    
        IconLabel  {
            text: "This & That"
        }
    }
    

    Displays "This _That"

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I don't have an answer as for the why, however your can use && and it will show you the char you want.

      That behaviour makes me think of the accelerators for menus.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      aha_1980A 1 Reply Last reply
      1
      • E Offline
        E Offline
        EStudley
        wrote on last edited by
        #3

        Thank you! So annoying, I thought I was going to have to recreate IconLabel...

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          I don't have an answer as for the why, however your can use && and it will show you the char you want.

          That behaviour makes me think of the accelerators for menus.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @SGaist

          That behaviour makes me think of the accelerators for menus.

          I guess that will be the reason for the why.

          Qt has to stay free or it will die.

          1 Reply Last reply
          0
          • jpnurmiJ Offline
            jpnurmiJ Offline
            jpnurmi
            wrote on last edited by
            #5

            As others have pointed out, this behavior is indeed related to accelerator keys aka mnemonics. The internal IconLabel type is used by such controls that support mnemonics, which are marked by an ampersand. IconLabel seems to incorrectly pick an ampersand followed by whitespace. Presumably it shouldn't, so there is probably a bug involved too. Feel free to report a bug. ;)

            1 Reply Last reply
            2

            • Login

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