16,248
社区成员
发帖
与我相关
我的任务
分享
import QtQuick 1.0
Item {
id:zone_detail
width: 98
height: 98
property int m_state: 0
property string content1: ""
property string content2: ""
property string content3: ""
property bool m_dd: false;
function set_state(state_){
switch(state_){
case 0:
zone_detail.state = "";
break;
case 1:
zone_detail.state = "state1";
break;
case 2:
zone_detail.state = "state2";
break;
}
return state_;
}
Timer{
id: timer1
interval: 300;
onTriggered: {
zone_detail.m_dd = ture;
}
}
BorderImage {
id: border_image1
anchors.fill: parent
source: ..
Text {
id: text1
x: 0
y: 23
width: 98
height: 21
text: content1
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 18
}
Text {
id: text2
x: 0
y: 66
width: 49
color: "#ffffff"
text: content3
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 12
}
Text {
id: text3
x: 49
y: 66
width: 49
color: "#ffffff"
text: content2
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 12
}
}
MouseArea {
id: mouse_area1
anchors.fill: parent
onPressed: timer1.start();
onReleased: {
timer1.stop();
if(!m_dd){
m_state=set_state(m_state);
}
else{
m_state = set_state(0);
m_dd = false;
}
}
onPositionChanged:set_state(m_state);
}
states: [
State {
name: "state1";when: mouse_area1.pressed && m_state==0
PropertyChanges {
target: border_image1
source: "../../qml_vrf/qml_vrf/Resources/image/group_all/group_back_select.png"
}
},
State {
name: "state2";
PropertyChanges {
target: border_image1
source: ..
}
PropertyChanges {
target: text1
visible: false
}
PropertyChanges {
target: text2
visible: false
}
PropertyChanges {
target: text3
visible: false
}
},
State {
name: "state3";when: mouse_area1.pressed && m_state==1
PropertyChanges {
target: border_image1
source: ..
}
PropertyChanges {
target: text1
visible: false
}
PropertyChanges {
target: text2
visible: false
}
PropertyChanges {
target: text3
visible: false
}
},
State {
name: "state4";
PropertyChanges {
target: border_image1
source: ..
}
PropertyChanges {
target: text1
visible: false
}
PropertyChanges {
target: text2
visible: false
}
PropertyChanges {
target: text3
visible: false
}
},
State {
name: "state5";when: mouse_area1.pressed && m_state==2
PropertyChanges {
target: border_image1
source: ..
}
PropertyChanges {
target: text1
visible: false
}
PropertyChanges {
target: text2
visible: false
}
PropertyChanges {
target: text3
visible: false
}
}
]
}
import QtQuick 1.1
Rectangle {
width: 360
height: 360
property bool isLongHold:false
Rectangle
{
anchors.centerIn: parent
width: 60
height: 60
color: "lightblue"
Timer
{
id:timer
interval: 3000
onTriggered: isLongHold = true
}
MouseArea {
anchors.fill: parent
onPressed: timer.start()
onReleased:
{
timer.stop()
if(isLongHold)
{
console.log("long hold")
}
else
{
console.log("not long hold")
}
isLongHold = false
}
}
}
}