Donven 2012-01-13
翻译qml里的文字是,一般使用的 qsTr(),
但是如果在ListModel 里用,
比如:
ListModel { ListElement { title: qsTr( "Calendar" ) ; iconSource: "icons/calendar.png" }
则会报错
ListElement: cannot use script for property value
解决方案:
import QtQuick 1.0 ListModel { ListElement { iconSource: "icons/calendar.png" } ListElement { iconSource: "icons/develop.png" } ListElement { iconSource: "icons/globe.png" } ListElement { iconSource: "icons/mail.png" } ListElement { iconSource: "icons/music.png" } ListElement { iconSource: "icons/phone.png" } function title( index) { if ( title[ "text" ] === undefined) { title.text = [ qsTr( "Calendar" ) , qsTr( "Setup" ) , qsTr( "Internet" ) , qsTr( "Messages" ) , qsTr( "Music" ) , qsTr( "Call" ) ] } return title.text [ index] } }
然后在listview里设置
text: view.model.title(view.currentIndex)
<div class="panel-body" style="height: 300px; width: 100%; overflow: auto;" data-platform-scroll="&q
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="icons/apple-touch-icon-114x114-precom