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 change total alignment

QTextEdit change total alignment

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.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
    mikefire345
    wrote on last edited by
    #1

    When there is no text selected in my QTextEdit, i want to be able to change the text alignment of all the text in my QTextEdit. Changing the alignment of QTextEdit seems to only change the first paragraph though. Is there a way to change all of the text at once? Thanks

    1 Reply Last reply
    1
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Move the cursor through all paragraphs and set their alignment. You can check the algorithm of "this solution in Python":http://www.thetoryparty.com/2009/05/14/fun-with-pyqt-setting-alignment-of-all-paragraphs-in-a-qtextedit/ and to port it to C++.

      http://anavi.org/

      1 Reply Last reply
      2
      • M Offline
        M Offline
        Matthew0x
        wrote on last edited by
        #3

        10 years later and the answer still works perfectly well

        ( ͡° ͜ʖ ͡°)

        What is interesting, is that (at least in my case), the input QTextEdit actually formats the entirety of text using the QAlignment, however the output QTextEdit formats only the first line.

        It's kind of as if the every row of NEW input (intercepted from user's keyboard) would inherit the QAlignment from the parent object, but this rule was somehow broken when setting the text programmatically from other type of object, like an array.

        Hence why that function is very useful, but it still kind of makes no sense (the general behavior of QTextEdit).

        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