2017-11-20 1 views
0

enter image description here어떻게 다른 대표

이 시안 사각형이 하나의 대표 인과 QML의 ListView에있다하여 ListView에 위임의 아이를 클립하지합니다. 나는 그 서클을 공중에 올려 놓을 때 확대하고 싶다. 문제는 아래 델리게이트에 의해 클리핑된다는 것입니다. 그리고 그것은 완벽하게 예상됩니다. 그러나이 동작을 어떻게 극복 할 수 있습니까?

다음은 예를 들어 코드입니다 :

import QtQuick 2.7 
import QtQuick.Controls 1.4 

ApplicationWindow { 
    id: rootWindow 

    visible: true 
    width: 640 
    height: 480 
    color: "white" 

    ListView { 
     anchors.fill: parent 
     model: 15 
     spacing: 5 
     delegate: Rectangle { 
      width: parent.width 
      height: 30 
      color: "cyan" 
      border.width: 1 
      border.color: "black" 
      clip: false 

      Rectangle { 
       property real k: mouseArea.containsMouse ? 5 : 1 
       anchors.centerIn: parent 
       height: parent.height * 0.5 * k 
       width: height 
       radius: width/2 
       color: "yellow" 
       border.width: 1 
       border.color: "black" 

       MouseArea { 
        id: mouseArea 
        anchors.fill: parent 
        hoverEnabled: true 
       } 

       Behavior on k { PropertyAnimation { } } 
      } 

      // layer.enabled: true // why this clips childs ??? 
     } 
    } 
} 

추가 질문 : 대리자에 대한 layer.enabled 왜 아이의 클립 시작? 이 속성으로 클리핑을 제거하는 방법은 모두 true로 설정되어 있습니까?

+0

'Rectangle' 구성 요소에서'clip : false'가 작동합니까? – DJMcMayhem

+0

@DJMcMayhem 예, 작동합니다 (layer.enabled : true 제외). delegate 인 AFAIK에게는'clip'이 기본적으로 비활성화되어 있으므로이 라인은 실제로 중복됩니다. – rsht

+0

추가 질문은 첫 번째 질문과 관련이 없으므로 추가 질문을하십시오. – derM

답변

2

델리게이트가 호버링 될 때 z 값을 올리면 호울 위임자가 나머지 위에 렌더링됩니다.

import QtQuick 2.7 
import QtQuick.Controls 1.4 

ApplicationWindow { 
    id: rootWindow 

    visible: true 
    width: 640 
    height: 480 
    color: "white" 

    ListView { 
     anchors.fill: parent 
     model: 15 
     spacing: 5 
     delegate: Rectangle { 
      width: parent.width 
      height: 30 
      color: "cyan" 
      border.width: 1 
      border.color: "black" 
      clip: false 

//*********v see this line!    
      z: mouseArea.containsMouse ? 2 : 1 

      Rectangle { 
       property real k: mouseArea.containsMouse ? 5 : 1 
       anchors.centerIn: parent 
       height: parent.height * 0.5 * k 
       width: height 
       radius: width/2 
       color: "yellow" 
       border.width: 1 
       border.color: "black" 

       MouseArea { 
        id: mouseArea 
        anchors.fill: parent 
        hoverEnabled: true 
       } 

       Behavior on k { PropertyAnimation { } } 
      } 
     } 
    } 
} 
+0

나는이 방법을 시도했다고 생각했다. 고맙습니다! – rsht

+0

어쩌면 당신은 델리게이트 루트 대신에 노란색 원 자체의'z' 값을 올리려고했습니다. – derM