问题描述
我正在尝试学习Qt,并将头放在UI forms周围。该文档指出,我应该能够在实现文件中实现标头。但是,我不能这样做(也不能覆盖设计器中分配的任何属性)。
这是我的BasicWindowForm.ui.qml:
Flutter clean
这是设计模式下的外观:
这是BasicWindow.qml:
导入QtQuick 2.4
import QtQuick 2.4
import QtQuick.Controls 2.12
Item {
id: element
width: 400
height: 400
property alias quitButton: quitButton
Rectangle {
id: rectangle
x: 100
width: 200
height: 86
color: "#ffffff"
radius: 10
border.width: 3
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 25
}
Row {
id: row
y: 222
height: 100
layoutDirection: Qt.RightToLeft
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
Button {
id: quitButton
text: qsTr("Quit")
}
}
}
/*##^##
Designer {
D{i:1;anchors_y:20}D{i:2;anchors_width:200;anchors_x:21}
}
##^##*/
和main.qml:
BasicWindowForm {
quitButton.text: "Lorem"
quitButton.onClicked: Qt.quit()
}
如果我将处理程序移至main.qml文件,则它将起作用。但是,就像这里一样,单击按钮没有任何作用,并且仍显示为“退出”。
我在做什么错了?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)