[Interest] Font width and height in pixels based on language Qt 5.12.8

Thiago Macieira thiago.macieira at intel.com
Mon May 18 17:00:58 CEST 2020


On segunda-feira, 18 de maio de 2020 00:05:15 PDT Ramakanth Kesireddy wrote:
> Can you let me know if it possible to determine the font text width and
> height in pixels using fontmetrics based on language for the fixed button
> width?
> 
> Basically to fix number of characters for translation ts files in the fixed
> button width based on language both for latin and non-latin languages.
> 
> Any other suggestions?

Redesign. Your problem is upside down.

Given some text, you can calculate at *runtime* how wide and how tall it is, 
in pixels. You can't pre-calculate it because the fonts and other settings may 
change at runtime from device to device, OS to OS. What fits in one case may 
not in the other.

Use layouts to automatically adjust based on the text you actually have. If 
necessary, use the automatic placement of ellipsis if the text is too big by 
setting an upper constraint, but use this as a last resort as some information 
will be left out.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products





More information about the Interest mailing list