2014-02-25 2 views
4

내가 다음 QML 유사한 중첩있는 ScrollView를 가지고 마우스 휠에 응답하지 않습니다중첩있는 ScrollView는

import QtQuick 2.0 
import QtQuick.Controls 1.1 

Rectangle { 
    width: 200 
    height: 600 

    ScrollView { 
     id: sView 
     anchors.fill: parent 
     ListView { 
      id: list 
      boundsBehavior: Flickable.StopAtBounds 
      clip: true 
      focus: true 
      interactive: true 
      model: 5 
      delegate: Component { 
       MouseArea { 
        id: hoverArea 
        width: 100 
        height: 200 
        onClicked: list.currentIndex = index; 

        Rectangle { 
         id: fauxParent 
         anchors.fill: parent 
         border.width: 1 
         border.color: "black" 

         Rectangle { 
          anchors.top: parent.top 
          anchors.left: parent.left 
          height: parent.height 
          width: parent.width/2 
          border.width: 1 
          border.color: "purple" 
          color: "green" 
          Text { 
           anchors.centerIn: parent 
           text: "stuff" 
          } 
         } 
         ScrollView { 
          //parent: sView 
          anchors.top: fauxParent.top 
          anchors.right: fauxParent.right 
          height: fauxParent.height 
          width: fauxParent.width/2 

          ListView { 
           model: 3 
           delegate: Component { 
            Rectangle { 
             radius: 10 
             height: 100 
             width: 100 
             color: "blue" 
            } 
           } 
          } 
         } 
        } 
       } 
      } 

     } 
    } 
} 
내부있는 ScrollView가 마우스 휠에 응답하지 않습니다 것을 제외하고, 제대로 실행 것으로 보인다

: 외부 ScrollView가 해당 이벤트를 차단합니다. 이 문제에 대한 연구에서 발견 한 유일한 해결책은 내부 scrollview의 부모를 외부 스크롤 뷰에 직접 설정하는 것입니다 (parent: sView 줄의 주석 처리를 제거하십시오). 불행히도, 이것은 5 개의 scrollview 델리게이트를 모두 바깥 쪽 scrollview의 오른쪽 위 모서리에 위치시킵니다. ScrollView 자체가 부모를 기준으로 위치를 잡는 것 같습니다.

레코드의 경우 실제 응용 프로그램은 스크롤 영역에 페이지의 큰 섹션을 래핑하여 사용자가 현재 창 크기의 범위를 벗어날 수있는 섹션에 액세스 할 수있게합니다. 하지만이 섹션의 내용에는 일부 다양한 스크롤 뷰를 비롯하여 다양한 용도로 다양한 컨트롤이 있습니다. 따라서 창에 비해 너무 큰 일반 콘텐츠 세트를 다른 방법으로 이동하는 방법도 허용됩니다.

이것은 Windows 데스크톱 앱이므로 모바일 관련 문제는 고려하지 않아도됩니다.

답변

0

스크롤 이벤트를 처리하는 네 개의 요소를 중첩했습니다.

왜 ScrollView를 ListView에 배치합니까?

ScrollViews를 제거하면 마우스 휠이 정상적으로 작동합니다.

Rectangle { 
    width: 200 
    height: 600 
    ListView { 
     anchors.fill: parent 
     id: list 
     boundsBehavior: Flickable.StopAtBounds 
     clip: true 
     focus: true 
     interactive: true 
     model: 5 

     delegate: Component { 
      MouseArea { 
       id: hoverArea 
       width: 100 
       height: 200 
       onClicked: list.currentIndex = index; 

       Rectangle { 
        id: fauxParent 
        anchors.fill: parent 
        border.width: 1 
        border.color: "black" 

        Rectangle { 
         anchors.top: parent.top 
         anchors.left: parent.left 
         height: parent.height 
         width: parent.width/2 
         border.width: 1 
         border.color: "purple" 
         color: "green" 
         Text { 
          anchors.centerIn: parent 
          text: "stuff" 
         } 
        } 
        ListView { 
         anchors.top: fauxParent.top 
         anchors.right: fauxParent.right 
         height: fauxParent.height 
         width: fauxParent.width/2 
         model: 3 

         delegate: Component { 
          Rectangle { 
           radius: 10 
           height: 100 
           width: 100 
           color: "blue" 
          } 
         } 
        } 
       } 
      } 
     } 
    } 
} 

이의 스크롤 막대 모양 놓칠 경우 How to create scrollbar in QtQuick 2.0?

관련 문제