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. Use Text.RichText and fontSizeMode: Text.Fit together?

Use Text.RichText and fontSizeMode: Text.Fit together?

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

    I tried to create a Text element with rich text that auto-fits font size to fill its parent:

    Rectangle {
               color: "white"
               width: 300
               height: 300
    
               Text {
                            text: "12<span style=\"font-weight:100\">3</span>"
                            fontSizeMode: Text.Fit                      
                            font.pointSize: 80
                            textFormat: Text.RichText
                            anchors.fill: parent
                            minimumPointSize: 20
               }
    }
    

    However, it only works when I remove textFormat: Text.RichText. Otherwise, the text is not scaled.
    It works with textFormat: Text.StyledText, but then I can't use advanced formattings (I need the font weight to be changed).

    Is it possible to achieve auto fitting with rich text somehow?

    1 Reply Last reply
    1

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved