Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Aligning text using QTextDocument

    General and Desktop
    2
    2
    2359
    Loading More Posts
    • 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
      Endless last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • First post
          Last post