小弟最近用qtquick做pc应用,在用listview的时候,在listview的样式中加入了一个button但是没有了button的点击效果,只有样式的的鼠标点击效果,还望大神给解
决下; 类似代码如下:
import QtQuick 2.7
import QtQuick.Window 2.2
import QtQuick.Controls 2.1
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
property var boxarray: [];
MouseArea {
anchors.fill: parent
}
Rectangle{
anchors.fill: parent;
Button{
anchors.horizontalCenter: parent.horizontalCenter;
anchors.top: parent.top;
width: 50;
height: 40;
onClicked: {
frid.model.append({"name": "118"})
}
}
Component{
id: commmm;
Rectangle{
id: rrttc
width: frid.cellWidth;
height: frid.cellHeight;
color: GridView.isCurrentItem ? "red" : "blue"
Text {
text: name;
color: rrttc.GridView.isCurrentItem ? "blue" : "red"
}
Button{
anchors.bottom: parent.bottom;
anchors.right: parent.right;
width: 30;
height: 30;
onClicked: {
console.log("2222")
}
}
MouseArea{
anchors.fill: parent;
onClicked: {
frid.currentIndex = index;
console.log("1111")
}
}
}
}
GridView{
id: frid
anchors.top: parent.top;
anchors.topMargin: 40;
anchors.left: parent.left;
anchors.right: parent.right;
anchors.bottom: parent.bottom;
model: contactModel;
focus: true;
highlight: Rectangle{color: "lightsteelblue"; radius: 4}
delegate: commmm
}
ListModel{
id: contactModel
ListElement{
name: "111";
}
ListElement{
name: "112";
}
ListElement{
name: "113";
}
ListElement{
name: "114";
}
ListElement{
name: "115";
}
}
}
}
这是一个类似的代码,就是运行起来的话button的点击效果没有也就是只打印“1111”不会打印“2222”,也就是button根本不能被点击,看一些其他的貌似是冲突了,有没有什么解决方法呢