编辑页面 qml代码
import QtQuick 2.0
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
Rectangle {
width: 300
height: 300
Column {
anchors.top: parent.top
anchors.topMargin: 6
anchors.left: parent.left
anchors.leftMargin: 6
anchors.margins: 6
spacing: 10
Row {
spacing: 3
Button {
text: "挂单"
}
Button {
text: "结账"
}
Button {
text: "关闭"
}
}
Row {
spacing: 3
Label {
width: 70
text: "会员信息:"
}
TextField {
id: memberinfo
}
Button {
text: "查询"
onClicked: {
searchMember.show()
}
}
}
Row {
spacing: 3
Label {
width: 70
text: "商品信息:"
}
TextField {
}
Button {
text: "查询"
}
}
Row {
spacing: 3
Label {
width: 70
text: "消费金额:"
}
TextField {
}
}
Row {
spacing: 3
Label {
width: 70
text: "现金支付:"
}
TextField {
}
}
Row {
spacing: 3
Label {
width: 70
text: "银联支付:"
}
TextField {
}
}
Row {
spacing: 3
Label {
width: 70
text: "找 零:"
}
TextField {
}
}
Row {
spacing: 3
Label {
width: 70
text: "备 注:"
}
TextArea {
}
}
}
Connections {
target: searchMember
onSelectedValue: {
searchMember.hide()
var retValue = searchMember.retValue
memberinfo.text = retValue["name"]
}
}
SearchMember {
id: searchMember
modality: Qt.WindowModal
}
}
选择信息页面的qml代码
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import "ajax.js" as Ajax
Window {
id: searchMember
width: 600
height: 600
property var retValue
signal selectedValue(string value)
ColumnLayout {
anchors.fill: parent
Row {
TextField {
}
Button {
text: "查询"
onClicked: {
Ajax.get("http://192.168.1.105/ui/member/member/listJsonAjax1.php",
function (result, json) {
console.log(result.toString())
console.log(json.toString())
console.log(json.code)
console.log(json.retValue)
console.log(json.retValue)
console.log(json.message)
console.log(json)
memberModel.clear()
for (var i = 0; i < json.retValue.length; i++) {
console.log(typeof (json.retValue))
memberModel.append(json.retValue)
}
})
}
}
}
TableView {
id: tableview1
Layout.fillWidth: true
Layout.fillHeight: true
TableViewColumn {
id: checkedColumn
role: "checked"
title: qsTr("Checked")
delegate: Button {
text: qsTr("选择")
onClicked: {
console.log(styleData.row)
var value = memberModel.get(styleData.row)
console.log(memberModel)
console.log(value)
searchMember.retValue = value
searchMember.selectedValue("a")
}
}
}
TableViewColumn {
role: "name"
title: "会员名称"
width: 100
}
TableViewColumn {
role: "card"
title: "卡号"
width: 200
}
TableViewColumn {
role: "mobile"
title: "手机号码"
width: 200
}
model: memberModel
}
ListModel {
id: memberModel
}
}
}
在window7 使用mingw进行编译运行正常。使用安卓编译器编译完后,在真机上测试发现弹出SearchMember窗体的时候,和tableview点击选择按钮的时候,整个程序都是卡着不动的,要等好久才有反映。有没有人遇到过类似的问题。望指教、。