【问题标题】:how to get set font of text with another text's font如何使用另一个文本的字体设置文本字体
【发布时间】:2018-12-04 17:20:53
【问题描述】:

我在 qml 中有两个文本项,我想将第一个文本的字体设置为第二个文本的字体。我该怎么做?

例如

Text{
  id:t1
  //some code
  //anchors ..etc
}

Text{
  //set font = t1.font or something similar
}

【问题讨论】:

    标签: qt fonts qml


    【解决方案1】:

    你快到了,你需要使用冒号:来分配属性:

    Text {
       id: txt1
       font.bold: true
       text: "Hello"
    }
    
    Text {
       id: txt2
       font: txt1.font
       text: "World"
    }
    

    【讨论】:

      猜你喜欢
      • 2015-11-02
      • 1970-01-01
      • 2023-04-06
      • 2019-01-30
      • 2016-10-31
      • 2013-03-05
      • 2013-10-08
      • 2011-01-14
      相关资源
      最近更新 更多