Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Prevent QML Text element from stripping whitespace
Qt 6.12 LTS is out! See what's new in the release blog

Prevent QML Text element from stripping whitespace

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 551 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.
  • W Offline
    W Offline
    While_e
    wrote on last edited by
    #1

    If I attempt to set a QML Text element's text property to say:

    text:"This line has space at the end     \n" + "but it will be stripped"
    

    The trailing whitespace at the end of the first line will be stripped away automatically once set. Is there any way to prevent or workaround this issue? I'm attempting to center the text,, but I want to be able to use the spaces to pad and justify some of the text if necessary.

    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
    • Unsolved