Solved How does a QML file set UTF-8 encoding?
-
QUrl source(“qrc:/qmlTest.qml”); QQuickWidget* quickWidget = new QQuickWidget; quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView ); quickWidget->setSource(source); import QtQuick 2.8 import QtQuick.Controls 2.1 Rectangle { id: mapWindow Text{ x:0 y:0 font.family:"Alibaba PuHuiTi" font.pointSize:7 text:"test" color:"#0AAAB1" } }
-
@mirro Can you be more precise?
Do you mean the encoding of the content of a QML source code file? -
@jsulm said in How does a QML file set UTF-8 encoding?:
a QML source code file
Yes, i mean a QML source code file.
-
@mirro The encoding of your sources depends on the editor configuration.
-
Why can't you upload an image using the following code?
[img]https://s1.ax1x.com/2020/07/29/aZPKqe.png[/img] -
@mirro Image upload does not always work here.
-
@mirro said in How does a QML file set UTF-8 encoding?:
Yes, i mean a QML source code file.
But is your QML file encoded as UTF-8?
In Qt Creator look at the upper right corner of the editor View:
Or with menu Edit => Select Encoding... and choose UTF-8:
You can also ensure always using UTF-8 with menu Tools => Options in Text Editor select Tab Behavior to select default encoding as UTF-8.
-
I didn't describe it very well,
I use Qt Creator 4.15, how to show encoding format here? it is convenientEdit1:
tool->options->text editor->display,
I find that -
@make2 said in How does a QML file set UTF-8 encoding?:
how to show it?
The file you opened is not using UTF-8.
To make UTF-8 the default for source code files check the "Text Editor/Behaviour/Default Encoding" - it should be set to UTF-8.