Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. qsTr not work with conditional operator

qsTr not work with conditional operator

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 411 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • alemioA Offline
    alemioA Offline
    alemio
    wrote on last edited by
    #1

    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
    }

    1 Reply Last reply
    1
    • F Offline
      F Offline
      flowery
      wrote on last edited by
      #2

      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
      }
      }

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved