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. Font bearing and Qt::TextWordWrap
Forum Updated to NodeBB v4.3 + New Features

Font bearing and Qt::TextWordWrap

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 655 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.
  • F Offline
    F Offline
    fsilva
    wrote on last edited by
    #1

    About a month ago I was having problems with QPainter.drawText writing outside of the bounds of the rectangle which I solved with the help of someone at Stackoverflow ([url=http://stackoverflow.com/questions/23737591/qpainter-drawtext-italic-writes-outside-of-the-rectangle]post here[/url]) which I solved using QFontMetrics::leftBearing and QFontMetrics::rightBearing.

    As stated in the SO post I wanted to avoid having extra space to the left or to the right so I am only applying an offset to the left or to the right when the first or last character is problematic (has a negative bearing). Of course everything was fine until someone decided to add Qt::TextWordWrap into the mix. In this case any of the middle lines can span outside of the rectangle.

    I would like to know if I am following the best approach in the first place and also if there is any way to determine where will QPainter insert line breaks when drawing with Qt::TextWordWrap.

    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