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. Change font size of button dynamically
Forum Updated to NodeBB v4.3 + New Features

Change font size of button dynamically

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 376 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.
  • Y Offline
    Y Offline
    ynatynat
    wrote on last edited by
    #1

    When a text of Button is long, the text will be omit.
    But I wish to show all of text by changing font size dynamically.
    How to do ?

    Button{
        text:"very long name XXXXXXXXXXXX"
    //font.pointSize: //<======change it dynamically
    }
    
    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      First you need to know the size the text is going to require. You can determine that using a FontMetrics object.
      Using that, you should be able to write a function that progressive decreases font size until the size fits

      Y 1 Reply Last reply
      0
      • A Asperamanca

        First you need to know the size the text is going to require. You can determine that using a FontMetrics object.
        Using that, you should be able to write a function that progressive decreases font size until the size fits

        Y Offline
        Y Offline
        ynatynat
        wrote on last edited by
        #3

        @Asperamanca
        thank you. As you tell me, FontMetrics is good to know text size.
        But, it doesn't show actual size text of label which placed in layout.
        I gave up.

        1 Reply Last reply
        0
        • Y ynatynat has marked this topic as solved on

        • Login

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