[SOLVED]HTML font face tag not work with QML Text



  • <font face> tag have no effect, while <font color> and <font size> still okay. Did I do something wrong?
    Please explain that for me, thank you.

    @import QtQuick 2.3

    Rectangle {
    width: 360
    height: 360
    color: "black"
    MouseArea {
    anchors.fill: parent
    onClicked: {
    //Qt.quit();
    }
    }

    Text {
        anchors.top: parent.top
        //font.family: "Courier"
        text: "<font face='Courier' color='green' size='7'>Hello World</font>"
    }
    Text {
        anchors.bottom: parent.bottom
        //font.family: "Arial"
        text: "<font face='Arial' color='yellow' size='8'>Hello World</font>"
    }
    

    }

    @

    Ah sorry, my company doesn't allow uploading image. The code above show two text with same font, different color and different size.


  • Moderators

    Hi,

    Welcome to Qt Devnet.
    Text element does support HTML style tags but not all of them but it certainly does which you have mentioned.
    You need to set textFormat: Text.RichText property for Text element.
    More info "here":http://doc.qt.io/qt-5/qml-qtquick-text.html#textFormat-prop.



  • It's work!
    Thank p3c0! Thank you very much!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.