0
如何爲login.qml文件生成.cpp和.h文件?從qt創建器中的..qml文件生成.cpp和.h文件
我爲登錄頁面編寫了一個.qml文件。
我的代碼如下
進口QtQuick 1.0
Rectangle{
id:screen
color: "lightgray"
width: 3000; height:2700
Column {
id: column1
width: 201
height: 400
Row {
id: row1
width: 40
height:50
TextInput {
id: userName
x: 40
y: 18
width: 80
height: 20
text: qsTr("UserName")
font.pixelSize: 12
}
Rectangle {
id: rectangle1
x: 115
y: 18
width: 80
height: 20
color: "#ffffff"
}
}
Row {
id: row2
width: 40
height: 50
TextInput {
id: password
x: 40
y: 18
width: 80
height: 20
text: qsTr("Password")
font.pixelSize: 12
}
Rectangle {
id: rectangle2
x: 115
y: 18
width: 80
height: 20
color: "#ffffff"
}
}
Row {
id: row3
x: 8
y: 113
width: 40
height: 50
Rectangle {
id: rectangle3
x: 8
y: 8
width: 80
height: 20
color: "#ffffff"
Text {
id: login
text: "Login"
x:4
y:4
width:30
height:10
font.pixelSize: 12
}
}
}
}
MouseArea {
anchors.fill: parent
onClicked: {
myclass.doStuffFromQmlSlot();
Qt.quit();
}
}
}
'import QtQuick 1.0' - > Qt和Qt Creator的版本是什麼? QtQuick 1在Qt 5中已棄用.Qt Creator中可能有一個「Qt Quick Application」項目模板(至少有更新的版本,不確定較舊的版本),只需創建一個並替換那裏的QML(可能會改變main.cpp來加載你的文件),那麼你可以爲你的代碼構建一個真正的可執行文件。 – E4z9
你爲什麼想這樣做? 在Qt企業版中有一個Qt Quick Compiler,可以將qml文件透明地編譯爲C++。 – GrecKo