Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED]HTML font face tag not work with QML Text
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    diepdtnse03145
    wrote on 23 Jan 2015, 02:34 last edited by
    #1

    <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.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 23 Jan 2015, 04:56 last edited by
      #2

      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.

      157

      1 Reply Last reply
      0
      • D Offline
        D Offline
        diepdtnse03145
        wrote on 23 Jan 2015, 13:27 last edited by
        #3

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

        1 Reply Last reply
        0

        1/3

        23 Jan 2015, 02:34

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved