FourtyTwo
FourtyTwo

Reputation: 1741

How to find out which fonts are available in qml?

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?

Upvotes: 13

Views: 13024

Answers (4)

Gaël
Gaël

Reputation: 51

You can improve the previous answer by adding this

Text {
     font.family: modelData
     anchors.centerIn: parent
     text: modelData;
}

Upvotes: 3

Mido
Mido

Reputation: 1112

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; 
        }
    }
}

Upvotes: 24

BlueMagma
BlueMagma

Reputation: 2505

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.

Upvotes: 13

Dcow
Dcow

Reputation: 1463

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

Upvotes: 4

Related Questions