2014-09-14 3 views
0

2x2 Gridlayout이 있습니다. 모든 항목은 왼쪽 정렬이고 각 열은 전체 공간의 50 %를 차지합니다.GridLayout에서 정렬 된 항목 이동

이제 GridLayout 20 픽셀의 4 개 항목 중 하나를 오른쪽으로 이동하고 싶습니다. 어떻게 나야?

import QtQuick 2.2 
import QtQuick.Controls 1.2 
import QtQuick.Layouts 1.1 

Gridlayout { 
    rows: 2 
    flow: GridLayout.TopToBottom 
    TextEdit { 
     Layout.alignment: Qt.AlignLeft 
     text: "test 1" 
    } 
    Image { 
     // This one is supposed to be aligned left + 20 pixels 
     source: "cool-pic.jpg" 
    } 
    TextEdit { 
     Layout.alignment: Qt.AlignLeft 
     text: "test 3" 
    } 
    TextEdit { 
     text: "test 4" 
    } 
}  

답변

1

이 해결책을 찾았습니다. 그것은 작동하고 아마 당신을 위해 유용 할 것입니다. 원하는대로 너비를 변경할 수 있습니다

import QtQuick 2.2 
import QtQuick.Layouts 1.1 

GridLayout { 
    rows: 2 
    flow: GridLayout.TopToBottom 
    TextEdit { 
     Layout.alignment: Qt.AlignLeft 
     text: "test 1" 
    } 

    Row{ 
     Rectangle{width: 20;height:parent.height; color:"transparent"} 
    Image { 
     // This one is supposed to be aligned left + 20 pixels 
     source: "sub/tst.jpg" 
    } 
    } 
    TextEdit { 
     Layout.alignment: Qt.AlignLeft 
     text: "test 3" 
    } 
    TextEdit { 
     text: "test 4" 
    } 
} 
+0

편의상 죄송합니다. 4x 텍스트 편집기로 원하지만 실제로 이미지를 이동해야합니다. 원래 질문을 업데이트했습니다. – Hedge

+0

@Hedge 전적으로 내 대답을 업데이트했습니다. 제발 제발 편집하십시오. – Chernobyl

+0

놀라운! 불편을 드려 대단히 죄송합니다. – Hedge

관련 문제