I’m developing a cross-platform app with Qt 5.9 (+ Felgo) for our coworking space in Taiwan.
All of users are Traditional Chinese native, so I’m using UTF-8 Chinese strings in my app.
Most of the parts seems ok, but the QML Button with UTF-8 Chinese only show me empty spaces.
On Desktop it works fine, but on Android (both in emulator and on phone) the problem occured.
And, if I set the button.text = “中文 UTF-8 Chinese” again later in Component.onComplete, it display correctly.
Can I use Chinese (UTF-8) strings in the Button.text field?
If yes, what should I do to make it work?
Codes:
// imports
import Felgo 3.0
import QtQuick 2.0
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1
//import QtQuick.Controls.Material 2.1
import QtPositioning 5.2
QML part
// QML Button parts
Rectangle {
id: containerBtn
height: dp(60)
radius: 5
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
border.color: "blue"
Button {
id: btn_reload_pic
text: "截圖.reload()"
//dropShadow: true
//icon: IconType.recycle
anchors.right: parent.horizontalCenter
//width: parent.width / 4
//radius: 5
onClicked: {
var currentTime = new Date();
currentSnapshot.snapshotURL = currentSnapshot.snapshotURL + "?t=" + currentTime
}
}
AppButton {
id: btnLock
text: "芝麻開門(或關門)"
dropShadow: true
icon: IconType.question
anchors.left: parent.horizontalCenter
width: parent.width / 4
radius: 5
onClicked: lockSwitch()
}
}
javascript set works
// Component.onComplete
btnLock.text = '芝麻關門';
Screenshots:
Button shows empty utf-8 chinese string [1]
after setting button.text later in onComplete [2]
Environments:
Qt 5.9
QtCreator 4.3.0
Felgo 2.12.1-1
Ubuntu 16.04 LTS 64bit
Android 7.0 API 24, x86 emulator / HTC 10
Test App: MOLiApp on Google Play (I cannot post link here)
[1]: https://i.stack.imgur.com/4JLlr.png
[2]: https://i.stack.imgur.com/bFSf4.png