//main.qml
import QtQuick 2.12
import QtQuick.Window 2.12
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
property double version: 1.2
Text {
id: m_txt
width: 100
height: 100
text: plus2(2, 3)
}
//无参
function myPrint(){
console.log("print() called.")
}
//带参,无返回值
function plus(num1, num2){
console.log("plus:" + num1 + " + " + num2 + " = " + (num1 + num2))
}
//带参,有返回值
function plus2(num1, num2){
return (num1 + num2)
}
//程序最后执行
Component.onCompleted: {
myPrint()
plus(1, 2)
}
}
qml 函数 function 无参 带参 有返回值
猜你喜欢
转载自blog.csdn.net/yongwoozzang/article/details/111054362
今日推荐
周排行