Change font size of button dynamically
Solved
QML and Qt Quick
-
wrote on 7 Aug 2023, 07:30 last edited by
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 }
-
wrote on 7 Aug 2023, 11:34 last edited by
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 -
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 fitswrote on 24 Aug 2023, 01:42 last edited by@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. -