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. QTextEdit Vertical Alignment Error.

QTextEdit Vertical Alignment Error.

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 3.7k 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.
  • P Offline
    P Offline
    Pada_
    wrote on last edited by
    #1

    Qt 5.4 I am using Windws8 64Bit and Linux 64Bit.

    Can not Vertically Align Text in QTextEdit?

    Horizontal alignment is normal for left, center, and right, but vertical alignment is not for top, middle, and bottom alignment.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Why such an outdated version of Qt ? Can you update ? Current version is 5.12.

      Can you show how you setup the content of your QTextEdit ?
      A minimal compilable example would be the test.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Why such an outdated version of Qt ? Can you update ? Current version is 5.12.

        Can you show how you setup the content of your QTextEdit ?
        A minimal compilable example would be the test.

        P Offline
        P Offline
        Pada_
        wrote on last edited by
        #3

        @SGaist

        Currently only 5.4 or 5.7 are available.

        textEdit->setAlignment(Qt::AlignLeft | Qt::AlignAbsolute | Qt::AlignVCenter);

        I set it like this.

        Then the text is left aligned and the Vertical Align is in the middle but it does not move.

        jsulmJ 1 Reply Last reply
        0
        • P Pada_

          @SGaist

          Currently only 5.4 or 5.7 are available.

          textEdit->setAlignment(Qt::AlignLeft | Qt::AlignAbsolute | Qt::AlignVCenter);

          I set it like this.

          Then the text is left aligned and the Vertical Align is in the middle but it does not move.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Pada_ You can't align vertically with setAlignment: https://doc.qt.io/qt-5/qtextedit.html#setAlignment
          "Valid alignments are Qt::AlignLeft, Qt::AlignRight, Qt::AlignJustify and Qt::AlignCenter (which centers horizontally)."

          I don't know whether there are other possibilities.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          3
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @jsulm Good catch, I misread the @Pada_ question.

            AFAIK, no, there's no other possibilities.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            P 1 Reply Last reply
            1
            • SGaistS SGaist

              @jsulm Good catch, I misread the @Pada_ question.

              AFAIK, no, there's no other possibilities.

              P Offline
              P Offline
              Pada_
              wrote on last edited by Pada_
              #6

              @SGaist @jsulm

              In the TableView model, you can apply a TextAlignmentRole to change the position of the text.
              Qt :: AlignLeft + Qt :: AlignVCenter or
              Using Qt :: AlignLeft + Qt :: AlignTop.

              However, when applied to QTextEdit in the same way, Vertical Alignment is not applied.

              What should I do?

              0_1558314216107_4d9deb84-32a5-4af1-9324-e3b7ac46ec27-image.png

              0_1558314221130_0166a915-9f65-4740-81cc-7b76c4d0820b-image.png

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You are comparing unrelated widgets.

                Can you show what exact result you want to achieve ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                P 1 Reply Last reply
                0
                • SGaistS SGaist

                  You are comparing unrelated widgets.

                  Can you show what exact result you want to achieve ?

                  P Offline
                  P Offline
                  Pada_
                  wrote on last edited by
                  #8

                  @SGaist

                  It's an irrelevant widget, but I want to do it in QTextEdit.

                  The purpose is to look like that.

                  jsulmJ 1 Reply Last reply
                  0
                  • P Pada_

                    @SGaist

                    It's an irrelevant widget, but I want to do it in QTextEdit.

                    The purpose is to look like that.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @Pada_ Like what? There is no image in your last post.
                    Why do you want to align text vertically in the center in QTextEdit? This is quite unusual.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    P 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @Pada_ Like what? There is no image in your last post.
                      Why do you want to align text vertically in the center in QTextEdit? This is quite unusual.

                      P Offline
                      P Offline
                      Pada_
                      wrote on last edited by
                      #10

                      @jsulm

                      I want to bet is the same as the above picture.

                      QTextEdit should also be vertically aligned to top, middle, and bottom.

                      The reason for using this feature is simple. I am creating an Editor personally. This is a required function.

                      jsulmJ 1 Reply Last reply
                      0
                      • P Pada_

                        @jsulm

                        I want to bet is the same as the above picture.

                        QTextEdit should also be vertically aligned to top, middle, and bottom.

                        The reason for using this feature is simple. I am creating an Editor personally. This is a required function.

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @Pada_ said in QTextEdit Vertical Alignment Error.:

                        I want to bet is the same as the above picture.

                        As I said there is no picture.

                        To make it clear: do you want to align text inside QTextEdit, or do you want to align QTextEdit in a layout?
                        I never used a text editor which aligns text vertically in the center.

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        P 1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @Pada_ said in QTextEdit Vertical Alignment Error.:

                          I want to bet is the same as the above picture.

                          As I said there is no picture.

                          To make it clear: do you want to align text inside QTextEdit, or do you want to align QTextEdit in a layout?
                          I never used a text editor which aligns text vertically in the center.

                          P Offline
                          P Offline
                          Pada_
                          wrote on last edited by
                          #12

                          @jsulm

                          0_1558421510467_3ffd915f-441b-4e5c-9ce5-b690933f15c0-image.png

                          I do not know if you will use it, but I need it now to develop. I want to arrange it like a photo inside a text item, not a layout.

                          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