Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Text implicit width
Qt 6.11 is out! See what's new in the release blog

Text implicit width

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

    Dear All

    I need to determine Text box width based on the text.
    I could see difference in sizes when I use Text metrics w.r.t. implicitWidth.
    For few of the cases textMetrics.width is not giving the actual width that is needed for the given text.

    But when I use implicitWidth i dont see any issue. Any thoughts on this?
    Is it Ok to use implicitWidth ?

    Text {
    id: txt
    text: qsTr("This is Test sample")

    	width: textMetrics.width //txt.implicitWidth
    	height: 14
    	elide: Text.ElideRight
    	font.pixelSize:   11
    	font.family:"Arial"
    	color: "#2B2D2E"
    	font.letterSpacing: 0
    
    }
    

    TextMetrics {
    id: textMetrics
    font: txt.font
    text: txt.text
    }

    Regards
    Chandra

    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