Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Slider LayoutMirroring.Enabled: false. Still mirrored in Arabic
Forum Updated to NodeBB v4.3 + New Features

Slider LayoutMirroring.Enabled: false. Still mirrored in Arabic

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 284 Views 2 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.
  • P Offline
    P Offline
    Pranshu Gupta
    wrote on last edited by
    #1

    // I don't want the slider to be mirrored for the Arabic region.
    // But setting LayoutMirroring.enabled: false doesn't seem to work

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.15
    import QtQuick.Layouts 1.15

    Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    ColumnLayout {
        LayoutMirroring.enabled: false
        Slider {
            LayoutMirroring.enabled: false
           from:1
           to:100
           value:90
           anchors.left: parent.left
        }
    
        Text {
            id: name
            text: qsTr("Slider Value :    ") + root.value
         }
    }
    

    }

    fbe66b76-1893-4491-a73d-1f1d07f31322-image.png

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rouven
      wrote on last edited by
      #2

      Hello,
      I encountered the same problem when mirroring application in qml. Since there are few questions and even fewer anwers regarding this subject I like to add my solution to this post so people in the future might find this:

      The problem is that the slider is a qml control and therefor has the mirrored property. The mirrored property indicates if the control (in this case the slider) is mirrored or not and determines this by looking at two things

      1. The LayoutMirroring.enabled attached property
        or
      2. The layout direction in the current locale. (Locale contains the current selected language and the direction defined within - you can check your locale direction by printing the textDirection property of the locale)

      So even if you set the LayoutMirroring.enabled to false controls will still mirror themselfs if you use e.g. and RTL locale, like arabic in this case.

      The solution for me was now to set an english (or any LTR) locale manually for the slider component so it won't use the arabic one and therefor is not forced to mirror anymore.

      Slider {
               locale:  Qt.locale("english")  // "english" must be replaced with your name for the english locale 
      }
      
      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