2016-10-11 2 views
1

나는 QML에서 사용자 지정 그룹 상자를 사각형 사라지는의 일부를 만들고있어 결정과 현재 나는 this은/보이지 않는 QML Qt는

처럼 보여이

Rectangle 
{ 
    anchors.fill: parent 
    color: "#55aaff" 
    Rectangle 
    { 
     id: combo_box 
     anchors.centerIn: parent 
     color: "transparent" 
     width: parent.width/2 
     height: parent.height/2 
     opacity: 0.3 
     Rectangle 
     { 
      anchors.fill: parent 
      color: "transparent" 
      border.color: "#ffffff" 
      border.width: 1 
      radius: 20 
     } 
    } 
    Rectangle 
    { 
     id: combo_box_title 
     anchors.verticalCenter: combo_box.top 
     anchors.left: combo_box.left 
     anchors.leftMargin: 30 
     width: 90 
     height: 20 
     opacity: 0.3 
     color: "#55aaff" 
    } 
    Text 
    { 
     id: combo_box_title_text 
     anchors.centerIn: combo_box_title 
     font.family: "Comic Sans MS" 
     font.pointSize: 9 
     color: "#e1e100" 
     text: "Game Settings" 
    } 

을 내 콤보 제목이 볼 수 있습니다 백그라운드에서의 Rectangle의 경계 내가 원하는 것은 Title 뒤에있는 Rectangle 테두리의 부분을 제거하는 것입니다.

문제점의 해결책은 있습니까? 아니면 다른 종류의 GroupBox를 사용할 수 있습니다. 당신은 Canvas과 흰색 테두리로 Rectangle 교체

+0

당신은 사용하여 선을 그리는 시도 할 수 있습니다 [캔버스 ] (http://doc.qt.io/qt-5/qml-qtquick-canvas.html) – user2436719

+0

나는 그것이 무시 무시한 것처럼 보이기 때문에 대문자로 된 텍스트를 제거해야한다고 생각한다. – folibis

+0

이 조건에서 캔버스를 사용하고 있습니까? 내 코드에서 볼 수 있듯이 여러 사각형이 있습니다. 어디에서 캔버스를 배치할까요? 첨부 된 스냅으로 볼 수 있듯이 캔버스에 둥근 선을 그릴 수 있습니까? 몇 가지 코드를 제공해 주시겠습니까? 감사합니다 –

답변

2

미리 감사드립니다 :

Canvas { 
    id: mycanvas 
    anchors.fill: parent 
    onPaint: { 
     var ctx = getContext("2d"); 
     ctx.strokeStyle = 'white'; 
     ctx.beginPath(); 
     ctx.moveTo(120, 0); 
     ctx.lineTo(mycanvas.width - 20, 0); 
     ctx.arc(mycanvas.width - 20,20,20,-Math.PI/2, 0); 
     ctx.lineTo(mycanvas.width, mycanvas.height - 20); 
     ctx.arc(mycanvas.width - 20,mycanvas.height - 20,20,0, Math.PI/2); 
     ctx.lineTo(20, mycanvas.height); 
     ctx.arc(20,mycanvas.height - 20,20,Math.PI/2,Math.PI); 
     ctx.lineTo(0, 20); 
     ctx.arc(20,20,20,Math.PI,-Math.PI/2); 
     ctx.lineTo(30, 0); 
     ctx.stroke(); 
    } 
} 

당신은 텍스트의 정확한 크기에 맞게 combo_box_title_text.contentWidth를 사용할 수는

+0

고마워요! 너 내 인생을 쉽게 만들었 어! :) –