我想使用RichText. 我试过<center>标签和text-align属性。它们都不起作用。
import QtQuick 2.0
import QtQml.Models 2.1
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
ApplicationWindow{
width: Screen.width; height: Screen.height; color: "#d5d6d8"
visible:true
Rectangle {
color: "#33cc94"
width: parent.width; height: parent.height
id : main
Flickable {
id:textArea
anchors.fill: parent
contentHeight: textBrowser.height
contentWidth: textBrowser.width
enabled: false
Text {
id:textBrowser
textFormat: Text.RichText
// visible:false
// text: "<center><img src=\"Icons/TroopCards/ArchersCard.png\" /></center>";
text: "<p style=\"text-align:center\">
<img src=\"Icons/TroopCards/ArchersCard.png\" />
</p>
<p style=\"text-align:center\">Some text at middle</p>";
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
如何在 QML 中使用 html 将图像居中?!
尝试这个:
Text {
id:textBrowser
anchors.horizontalCenter: parent.hrizontalcenter
textFormat: Text.RichText
text: "<p style=\"text-align:center\">
<img src=\"Icons/TroopCards/ArchersCard.png\" />
</p>
<p style=\"text-align:center\">Some text at middle</p>";
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1335 次 |
| 最近记录: |