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. Dynamic change text direction
Forum Updated to NodeBB v4.3 + New Features

Dynamic change text direction

Scheduled Pinned Locked Moved QML and Qt Quick
10 Posts 2 Posters 3.1k 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.
  • M Offline
    M Offline
    maxim.prishchepa
    wrote on 25 Aug 2014, 09:38 last edited by
    #1

    Hello All,
    I write multi languages app, and get a little issue with text direction, when user check Arabic language (where direction right to left) text written in English not change direction, i can't imagine why... i try to set a LayoutDirection.Enable to true, it's not give a result. but if i close the app, and open it again, the direction of text will be correct. Why it's that? Any ideas?

    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 25 Aug 2014, 11:27 last edited by
      #2

      Hi,

      According to "this":http://qt-project.org/doc/qt-5/qtquick-positioning-righttoleft.html#text-alignment it should be automatically be done.

      Following example works in Qt 5.3.1
      @
      Text {
      id: mytext
      anchors.fill: parent
      text: "Qt is Cool"
      }

      Button {
      anchors.bottom: parent.bottom
      text: "Arabic"
      onClicked: mytext.text = "مثال صغير"
      }

      Button {
      anchors.bottom: parent.bottom
      anchors.right: parent.right
      text: "English"
      onClicked: mytext.text = "Qt is Cool"
      }
      @

      157

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxim.prishchepa
        wrote on 25 Aug 2014, 11:36 last edited by
        #3

        yes, but i have a some text at Arabic and at English (mixed), for example lable "Name" write at Arabic, and TextInput contains name in English. Arabic text align correct (to right side), but English text align to left side, it's not correct (to vision of Arabic)

        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

        1 Reply Last reply
        0
        • P Offline
          P Offline
          p3c0
          Moderators
          wrote on 25 Aug 2014, 11:46 last edited by
          #4

          Do you mean like this:
          @
          onClicked: mytext.text = "مثال صغير; Qt is Cool"
          @

          ?

          157

          1 Reply Last reply
          0
          • M Offline
            M Offline
            maxim.prishchepa
            wrote on 25 Aug 2014, 12:08 last edited by
            #5

            i mean like this:
            @Text {
            text: "مثال صغير;"
            }
            TextInput {
            text: "Qt is Cool"
            }@

            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

            1 Reply Last reply
            0
            • P Offline
              P Offline
              p3c0
              Moderators
              wrote on 25 Aug 2014, 12:21 last edited by
              #6

              So you can do this:
              @
              TextInput {
              width: 200
              horizontalAlignment: Text.AlignRight
              text: "Qt is Cool"
              }
              @

              to align it to right.

              157

              1 Reply Last reply
              0
              • M Offline
                M Offline
                maxim.prishchepa
                wrote on 25 Aug 2014, 15:57 last edited by
                #7

                yes, but when user change language to english for example, in element "Text" will be english text, not Arabic, and i should to set alignment of TextInput to LeftToRight

                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  p3c0
                  Moderators
                  wrote on 26 Aug 2014, 06:05 last edited by
                  #8

                  bq. yes, but when user change language to english for example, in element “Text” will be english text, not Arabic, and i should to set alignment of TextInput to LeftToRight

                  Since your requirements need to override the default behavior for alignment of Text and TextInput you will have to change the alignments again. May be you can bind the horizontalAlignment property to the language chosen and accordingly set the required alignment.

                  157

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    maxim.prishchepa
                    wrote on 26 Aug 2014, 09:03 last edited by
                    #9

                    i try to do that, when i set a new value of language direction is not chenged. but if i close and open agein app, then direction will be changed.

                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      p3c0
                      Moderators
                      wrote on 26 Aug 2014, 09:16 last edited by
                      #10

                      Can you post the relevant code where it shows the binding to horizontalAlignment ?

                      157

                      1 Reply Last reply
                      0

                      1/10

                      25 Aug 2014, 09:38

                      • Login

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