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. Aligning text using QTextDocument
Forum Update on Monday, May 27th 2025

Aligning text using QTextDocument

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.0k Views
  • 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.
  • E Offline
    E Offline
    Endless
    wrote on 15 Dec 2014, 22:01 last edited by
    #1

    I'm using QTextDocument to put text into a QPixMap so it can go onto a QPushButton.

    I use the following methods: setPageSize, setHtml and drawContents. Everything works fine except that the text is left justified. I've looked over the methods for QTextDocument, but I can't find anything that would let me change the alignment to right justified. Which method should I be using?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 15 Dec 2014, 22:23 last edited by
      #2

      Hi,

      You might be looking for "QTextBlockFormat::setAlignment":http://doc.qt.io/qt-5/qtextblockformat.html#setAlignment

      Hope it helps

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

      1 Reply Last reply
      0

      1/2

      15 Dec 2014, 22:01

      • Login

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