2017-02-10 32 views
0

我公司目前正在努力设计一个旋转部件(270°,红)一QML应用程序,尽管代码使我烦恼
以下是我想要的布局,实现QML排列项目与旋转

Layout to be achieved

结果看起来像这样

Layout result

我编程misplaces红色矩形的代码
我认为的原因是,Qt保留的空间与不能被其他项目使用的未旋转红色矩形的宽度相同,因此将这些其他项目放在一边,在旋转项目和其他项目
出于同样的原因,我没有使用GridLayout,因为左列被拉伸。
以下是我编程

Item { 
id: item1 
anchors.fill: parent 

Label { 
    width: 0.6*parent.width 
    height: 0.15*parent.height 

    id: chartName 
    text: "Hallo Welt" 

    anchors.right: parent.right 
    anchors.bottom: chartImage.top 
    anchors.left: chartImage.left 
    anchors.top: parent.top 
} 

Item { 
//ChartView { 
    width: 0.6*parent.width 
    height: 0.25*parent.height 

    id: sideChart 

    //anchors.right: chartImage.top 
    //anchors.left: chartImage.bottom 
    anchors.bottom: chartImage.left 
    anchors.top: parent.left 

    rotation: 270 
} 

Image { 
    width: 0.6*parent.width 
    height: 0.6*parent.height 

    id: chartImage 

    anchors.top: chartName.bottom 
    anchors.right: parent.right 
    anchors.bottom: bottomChart.top 
    anchors.left: sideChart.right 

    source: "images/Objective_speckle.jpg" 
    fillMode: Image.PreserveAspectFit 
    cache: false 
} 

Item { 
// ChartView { 
     width: 0.6*parent.width 
     height: 0.25*parent.height 

     id: bottomChart 

     anchors.right: parent.right 
     anchors.left: chartImage.left 
     anchors.bottom: parent.bottom 
     anchors.top: chartImage.bottom 
} 
} 

帮助表示赞赏代码。

回答

0

问题通过使用GridLayout并放置一个大小为旋转矩形的Item来解决。这个物品有一个孩子,与父母交换宽度和高度,然后旋转270°,并锚定在中心。