Unsolved Underline(shortcut) is not getting displayed on changing the text on a button
-
A button is set text with "&Open" where shortcut is "Alt+O" but when I change the text to "Close"/"Cl&ose", the shortcut is getting removed.
How to retain the shortcut?import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 Pane { function on_update_open_button_text() { button.text = "Cl&ose" } Shortcut { id: sc sequence: "Alt+O" onActivated: { on_update_open_button_text() } } ColumnLayout { Button { id: button Layout.preferredWidth: 150 objectName: "openButtonObj" text: "&Open" onClicked: { on_update_open_button_text() } } } }
-
@MaruthiMarsh said in Shortcut gets removed on changing the text on a button:
the shortcut is getting removed
What does this mean exactly? What indicates that it is removed?
-
@fcarney I think I need to reframe the title. Basically what is happening is the underline under the character 'O' is not getting displayed when we change the button text to "Cl&ose" though it displays initially (when the text is "&Open").
-
@MaruthiMarsh would
button.text = "Cl<u>o</u>se"
work for your case ? -
@J-Hilk Yes, it does work. Thanks.
But why it doesn't work when '&' is used? -
@MaruthiMarsh I have no idea what
&O
is supposed to do and when I test it, id does nothing but print the & char.<u></u>
are rich text tags and the QMLl Text elements supports that, so I suggested to that :D