2014-02-13 36 views
0

我必须在左右滑动时拥有一个手势功能,但我还需要显示列表视图,但是尽快看到左右滑动的功能。你将如何处理这个问题?ListView上的鼠标区域qt快速

这是我的程序中的一小段代码片段。

CustomGestureArea{ 

    onSwipeRight:{ 
     // do something 
    } 
    onSwipeLeft:{ 
     // do something 
    } 
    // as soon as i put this in i loose the swipe functionality 
    ListView{ 
      anchors.fill:parent 
    } 

} 

我在想制作另一个自定义手势类,其中将包括列表视图,我会设置模型和其他需要的信息列表视图属性别名为正常工作,但在刷卡起来向下滚动列表(正如普通列表视图功能所期望的那样)。但我不知道如何开始。我的想法是列出这个。

GestureAreaListView{ 

    property alias list_model:list.model 
    // and all other needed properties etc 
    onSwipeRight:{ 
     // do my custom function 
    } 
    onSwipeLeft:{ 
     // do my custom function 
    } 
    onSwipeUp:{ 
     // do List view scroll up 
    } 
    onSwipeDown:{ 
     // do List view scroll down 
    } 
    // as soon as i put this in i loose the swipe functionality 
    ListView{ 
      anchors.fill:parent 
    } 
    ListView{ 
      id: list 
    } 
} 

回答

1

通过这样做,您的ListView位于CustomGestureArea之上,因此它将采取事件。

您可以强制zOrder将其置于顶端。

但你应该尝试只是为了反谁对谁的顶部:

ListView{ 

    CustomGestureArea{ 
     anchors.fill:parent 
     onSwipeRight:{ // do something 
     } 
     onSwipeLeft:{ // do something 
     } 
    } 
} 
+0

林几乎可以肯定,我尝试过这一点,它没有工作,但通过采取以上,只是修复了所有我的问题的办法。非常感谢你 – TheMan68