Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved QPainter.drawText() - where painter finished drawing text

    General and Desktop
    3
    5
    72
    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.
    • B
      BartoszT last edited by

      Can you somehow determine the area where the drawText function painted the text?
      I need to know (coordinates) where the painter finished painting the text.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        You can pass the exact rectangle where you want your text written. Isn't it enough for your purpose ?

        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
        • B
          BartoszT last edited by

          No, text can have many fonts and sizes.
          Is there any way to calculate pixel text width?

          1 Reply Last reply Reply Quote 0
          • Christian Ehrlicher
            Christian Ehrlicher Lifetime Qt Champion last edited by

            @BartoszT said in QPainter.drawText() - where painter finished drawing text:

            Is there any way to calculate pixel text width?

            Seee QFontMetrics

            Qt has to stay free or it will die.

            1 Reply Last reply Reply Quote 1
            • B
              BartoszT last edited by

              Thanks, it works.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post