Qt World Summit: Submit your Presentation

change character size automatically with longer translations in QtLinguist

  • Hey,

    i am currently working with qtLinguist in my (qt-qml-)Project. I do have a problem with translated strings that exceeds my scopes.

    Is there a way to change text sizes if the translation exceeds a number of pixles (or characters).

    If not, is there any way to highlight translated strings that are to long in qtLinguist so i can choose another translation for all the string that are to long?


  • Lifetime Qt Champion


    Do you mean elide your texts ?

  • No, I want to show the whole text but in a smaller pixelSize

  • Lifetime Qt Champion

    You would have to do that by hand using e.g. QFontMetrics to get the size of your text for a given font size

    Hope it helps

  • what i now do is:

          width: 466
          height: 75
          font.pixelSize: lineCount > 1 ?  30 : 40
          maximumLineCount: 2
          wrapMode: Text.Wrap
          elide: Text.ElideRight

    this does fix the Problem*.
    *But there can be of corse a binding loop because lineCount can be 2 with pixlesize 40 and 1 with a smaler linecount. I guess this is ok for me

  • i just found fontSizeMode: Text.VerticalFit. This will try to fix sizes