-1
A
回答
-1
The QT TextField使用中文和日文字符。所以這不是因爲TextField。也許可能會用你的TextField去除文本。 我會給你一個Qt Quick Control 2
我用中文字符測試的代碼。
的.pro
QT += qml quick
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
的main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
return app.exec();
}
main.qml
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
ApplicationWindow {
visible: true
width: 320
height: 480
title: qsTr("Hello World")
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex
Page1 {
}
Page {
Label {
text: qsTr("Second page")
anchors.centerIn: parent
}
}
}
footer: TabBar {
id: tabBar
currentIndex: swipeView.currentIndex
TabButton {
text: qsTr("First")
}
TabButton {
text: qsTr("Second")
}
}
}
Page1.qml
import QtQuick 2.7
Page1Form {
button1.onClicked: {
console.log("Button Pressed. Entered text: " + textField1.text);
label.text = textField1.text
}
}
Page1From.ui.qml
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
Item {
property alias textField1: textField1
property alias button1: button1
property alias label: label
GridLayout {
id: gridLayout
anchors.fill: parent
columns: 2
rows: 2
TextField {
id: textField1
Layout.fillHeight: true
Layout.fillWidth: true
placeholderText: qsTr("Text Field")
}
Button {
id: button1
text: qsTr("Press Me")
Layout.fillHeight: true
Layout.fillWidth: true
}
Label {
id: label
width: 213
height: 54
Layout.columnSpan: 2
Layout.fillHeight: true
Layout.fillWidth: true
}
}
}
qtquickcontrols2.conf
; This file can be edited to change the style of the application
; See Styling Qt Quick Controls 2 in the documentation for details:
; http://doc.qt.io/qt-5/qtquickcontrols2-styles.html
[Controls]
Style=Material
[Universal]
Theme=Dark
;Accent=Steel
[Material]
Theme=Dark
;Accent=BlueGrey
;Primary=BlueGray
+0
@DebashishSamantaray歡迎您:)你能否驗證我的答案plz? ^^ –
+1
我已經在qt字體中添加了特定的xxx.ttf文件,這是lib下它現在工作正常。 –
相關問題
- 1. 我的正則表達式如何支持諸如中文,日文,法文等多種語言
- 2. BlackBerry - 對中文的語言支持
- 3. 如何在FXML文檔中實現對JavaFX的語言支持?
- 4. 支持兩種語言在travis.ci文件
- 5. Android:minEms支持所有語言(例如中文,阿拉伯語)嗎?
- 6. 如何識別網站的內容語言,如英文,日文,中文等
- 7. 支持XML文字的編程語言
- 8. db文件支持哪些語言
- 9. Clojure的多語言文檔支持
- 10. 多語言支持如何在Drupal 8等平臺上工作?
- 11. IE中不支持中文和日文?
- 12. Android多語言和少數語言支持語言不支持語言區域
- 13. 如何編寫支持多種語言(如英語,中文和日語)的網頁?
- 14. 中文,日文等非拉丁語言的分割規則
- 15. 在Ajax文件上傳中需要多種語言支持
- 16. 在pyrocms中實現多語言支持
- 17. 在symfony 2中支持多種語言
- 18. 在DHTMLX或EXTJS4中支持RTL語言
- 19. 在Android中的語言支持
- 20. Log4Net:使用2字節語言(日語,中文等)登錄
- 21. Android語言支持
- 22. 多語言支持
- 23. PyroCMS語言支持
- 24. EditText語言支持?
- 25. Yocto語言支持
- 26. 支持RTL語言
- 27. ILGeoNames語言支持
- 28. 多語言支持
- 29. 在java中設置語言環境(語言支持)
- 30. 語法與支持語言
你怎麼輸入字符串? – vahancho