Special Characters



  • Hi,
    I changed from Qt 5.9.3 and Qt Creator 4.4.1 to Qt 5.10.0 and Qt 4.5.0.

    Now special charaters in labels, etc. are not displayed correctly in the application.

    If you need more informations, feel free to ask. Thanks!



  • Which platform?



  • @Leonardo
    Compiled and run on Windows 10.


  • Lifetime Qt Champion

    Hi,

    Can you show a picture of what you get ?

    A minimal sample application triggering that ?



  • @SGaist

    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):

    1_1515745273988_Qt5-10-0.JPG 0_1515745273987_Qt5-9-3.JPG



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



  • @Leonardo

    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.

    0_1516007255838_Qt5-10-0-2.JPG

    Thanks a lot!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.