13

I would like to know which fonts I can use in a QML environment for the font.family property. Are these fonts system-specific or are they built into the framework? Is there any way to list all available fonts?

BaCaRoZzo
  • 7,502
  • 6
  • 51
  • 82
FourtyTwo
  • 1,616
  • 2
  • 15
  • 43
  • Please, do not provide an answer as an edit: post an answer to your question describing the newer solution found. Thanks. – BaCaRoZzo Jul 16 '15 at 20:47

4 Answers4

23

This code will list all the accepted font families:

ListView {
    anchors.fill: parent; 
    model: Qt.fontFamilies()

    delegate: Item {
        height: 40; 
        width: ListView.view.width
        Text {
            anchors.centerIn: parent
            text: modelData; 
        }
    }
}
Semjon Mössinger
  • 1,798
  • 3
  • 22
  • 32
Mido
  • 1,092
  • 1
  • 9
  • 14
13

The fonts are system-specific so you should see what your system proposes.

If you are using QtCreator :

try putting your mouse over the end of your component name

Text <here> {
    ...
}

You should see a yellow light, click on it and you'll have an interface that allows to choose the font.

You can also access the interface with ctrl + alt + space while inside the component. Or with right click.

BlueMagma
  • 2,392
  • 1
  • 22
  • 46
4

This is a system-specific list of fonts, but you can specify external font from resources (QRC)

Dcow
  • 1,413
  • 1
  • 19
  • 42
3

You can improve the previous answer by adding this

Text {
     font.family: modelData
     anchors.centerIn: parent
     text: modelData;
}
Gaël
  • 41
  • 2