代码之家  ›  专栏  ›  技术社区  ›  TheMan68

ListView上的鼠标区域qt quick

  •  0
  • TheMan68  · 技术社区  · 12 年前

    我必须具有左右滑动的手势能力,但我还需要显示列表视图,但一旦显示,我就会看到左右滑动的能力。你将如何处理这个问题?

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

    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 回复  |  直到 12 年前
        1
  •  1
  •   BlueMagma    12 年前

    通过这样做,ListView位于CustomGestureArea的顶部,因此它会发生事件。

    你可以强迫zOrder登上榜首。

    但你应该尝试简单地反转谁在谁之上:

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