2017-11-07 5 views
0

私のアプリケーションの基本レイアウトを作成しようとしています。私はそれがこのように見えるようにしますthis。これはこれまでの私のセットアップです。Layout.fillHeight:trueを設定する矩形が見えないQtクイック2

main.qml

import QtQuick 2.7 
import QtQuick.Controls 2.0 
import QtQuick.Layouts 1.3 

ApplicationWindow { 
    visible: true 
    width: 640 
    height: 480 
    title: qsTr("basic layout") 

    ColumnLayout { 
     anchors.fill: parent 
     spacing: 0 

     Header { 
      Layout.fillWidth: true 
      height: 50 
     } 

     Body { 
      Layout.fillWidth: true 
      Layout.fillHeight: true 
     } 

     Footer { 
      Layout.fillWidth: true 
      height: 30 
     } 
    } 
} 

Header.qml

import QtQuick 2.7 
import QtQuick.Layouts 1.3 

Rectangle { 
    color: "red" 
} 

Footer.qml

import QtQuick 2.7 
import QtQuick.Layouts 1.3 

Rectangle { 
    color: "blue" 
} 

Body.qml

import QtQuick 2.7 
import QtQuick.Controls 2.0 
import QtQuick.Layouts 1.3 

Item { 
    RowLayout { 
     anchors.fill: parent 

     Rectangle { 
      color: "red" 

      width: 100 
      Layout.fillHeight: true 
     } 

     Rectangle { 
      color: "green" 

      width: 400 
      Layout.fillHeight: true 
     } 

     Rectangle { 
      color: "blue" 

      width: 400 
      Layout.fillHeight: true 
     } 

     Rectangle { 
      color: "black" 

      Layout.fillWidth: true 
      Layout.fillHeight: true 
     } 
    } 
} 

それが実行されたときBodyセクションでは、空白以外何もありません。 This what i get長方形を手作業でサイズ表示すると、長方形が表示されます。 anchors.fill: parentをのレベルにItemに追加しようとしました。それでも結果は同じです。何が間違っているのですか?

+0

を使用してRowLayoutに長方形の幅を設定する必要があります。私はちょうどあなたのコードをコピーし、それを実行し、あなたの最初の写真のように(ほとんど)見えます。 – derM

+0

私もあなたの問題を再現できません。私のために働いてください5.9.1 –

+0

これは私のオペレーティングシステムの問題かもしれませんか?私はLubuntuを使用しています。 Qt version 5.9.2 – CoderS

答えて

1

あなたは、私はあなたの問題を再現することはできません

Layout.preferredWidth: 400 

代わりの

width: 400 
関連する問題