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. How to make QTextLayout don't ignore 0x20(whitespace)
Qt 6.11 is out! See what's new in the release blog

How to make QTextLayout don't ignore 0x20(whitespace)

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 865 Views 2 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.
  • H Offline
    H Offline
    hobbe
    wrote on last edited by
    #1

    Hello guys,
    When I use QTextLayout to layout a multiline texts,if the QTextLine include 0x20 on the head or tail,QTextLayout will ignore and the QTextLine's width will less than tha actual width.
    How can I to fix it?
    My one solution is to replace 0x20 to 0xa0,but this will cause WordWrap don't work

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      First, the docs say that QTextLayout is a low-level class and not normally used. Then, what happens if you change your text to a fixed space font? You need to elaborate on what you mean by "width less than actual width". Does the character count of the QString in the layout not reflect the spaces, or are you just visually not seeing the text occupying the expected screen realestate?

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      2
      • H Offline
        H Offline
        hobbe
        wrote on last edited by
        #3

        I'm should use QTextLayout to achieve custom needs.when I set multi-lines text to QTextLayout ,if paragraph which have 0x20(white space) or \n,these whitespace words will be ignored and I need layout to calculate these words.

        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