【发布时间】:2019-10-12 20:24:36
【问题描述】:
我想从 linux shell 调用一个 qml-script 并传递一个文本作为参数,比如
./message.qml "hello this is a message"
或
/usr/bin/qt5/qml ./message.qml "hello this is a message"
qml 脚本应该显示该文本。
下面的示例 qml 脚本有效,但是显示的文本(“hello”)当然是静态的。是否可以在 qml 中查询命令行参数?
#!/usr/bin/qt5/qml
import QtQuick 2.2
Rectangle {
width: 1024
height: 600
Text {
anchors.centerIn: parent
text: "Hello" // here I want to have a text which is set in the call
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit()
}
}
}
【问题讨论】:
标签: linux qt shell qml command-line-arguments