Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

qsTr not work with conditional operator



  • I'm working with release 5.15.1.
    If I use qsTr with conditional operator, it doesn't translate the string

    Text{
    property bool checked: true
    text: checked? qsTr("Deselect all") : qsTr("Select all")
    }

    This is the workaround

    Text{
    property bool checked: true
    property string deselectAllString: qsTr("Deselect all")
    property string selectAllString: qsTr("Select all")
    text: checked? deselectAllString : selectAllString
    }



  • qsTr works with conditional operator .If translator is installed properly and checked value gets changed ,it should.for ex: following code works for me
    Text {
    id: tex
    property bool checkin: false
    anchors.centerIn: parent
    text: checkin ? qsTr("Hai How are you"): qsTr("bye")

    }
    MouseArea{
    anchors.fill: parent
    onClicked: {
    tex.checkin = !tex.checkin
    }
    }


Log in to reply