Qt World Summit: Submit your Presentation

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

  • 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"

  • Lifetime Qt Champion


    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.

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

  • Lifetime Qt Champion


    That behaviour makes me think of the accelerators for menus.

    I guess that will be the reason for the why.

  • 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. ;)

Log in to reply