Special Characters
-
Hi,
Can you show a picture of what you get ?
A minimal sample application triggering that ?
-
I wrote a little example and recognized, it only has effect of the text in a Button!
The source code:
import QtQuick 2.6 import QtQuick.Controls 2.1 //import QtQuick.Controls 2.3 // no change import QtQuick.Window 2.2 Window { visible: true width: 400 height: 150 title: qsTr("Hello World") Column { anchors.fill: parent spacing: 20 Text { anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Qt 5.10.0") // text: qsTr("Qt 5.9.3") } Text { anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Hello & Welcome") } Button { anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Hello & Welcome") } } }
And the displayed windows, compiled with Qt5.10.0 and Qt5.9.3 (msvc 2013):
-
Based on your image, it looks like Qt 5.10 has introduced a new feature. When we set the label for a button in a native application, we use & to specify a shortcut. For example, "&Open" would be rendered as "Open" with the first "O" underlined, meaning that Alt+o is a shortcut for that button. In your case, after the & there's a space, which we can also see underlined. When that's not the desired behavior, we should escape the & character. Try "Hello \\& Welcome" or "Hello && Welcome".
-
Thanks for that information. You're right: in Qt5.10 they added thw QML type Action. The AbstractButton has in Qt 5.10 an Action with a shortcut.
So i changed the code to
import QtQuick 2.6 import QtQuick.Controls 2.3 import QtQuick.Window 2.2 Window { visible: true width: 400 height: 150 title: qsTr("Hello World") Column { anchors.fill: parent spacing: 20 Text { anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Qt 5.10.0") } Text { anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Hello & Welcome") } ToolButton { anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Hello && Welcome") } } }
and now it works fine.
Thanks a lot!