2016-08-10 5 views
0

私は単純なRowLayoutの長方形を試しています。 (以下のコードを参照してください。)私はQtの創造主でこれを実行/コンパイルしようとすると、私が手に:私が使用しようとするのいずれかLayout.minimumWidth:200またはLayout { minimumWidth:200 }QML RowLayoutの添付プロパティを調整する

とき

qrc:/main.qml:31 Do not create objects of type Layout

Qtのdocumentation for RowLayoutは、最初の形式を示していワーキング。私は何が欠けていますか?

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

ApplicationWindow { 
    id: window 
    title: "RB3Jay" 
    width:1280; height:960 
    minimumWidth:600; minimumHeight:300 
    visible: true 

    Rectangle { 
     id: pseudocontent 
     height: parent.height - (header.height + footer.height) 
     color:'orange' 
     anchors { 
      top:header.bottom 
      bottom:footer.top 
      left:parent.left 
      right:parent.right 
     } 
    } 

    header: RowLayout { 
     id: header 
     spacing: 0 
     height: 100 
     width: parent.width 
     Rectangle { 
      color:'red' 
      Layout { 
       minimumWidth:200; maximumWidth:200; preferredWidth:200 
       fillHeight:true 
      } 
     } 
     Rectangle { 
      color:'green' 
      Layout { 
       minimumWidth: 200 
       preferredWidth: parent.width*0.7 
       fillWidth:true; fillHeight:true 
      } 
     } 
     Rectangle { 
      color:'blue' 
      Layout { 
       minimumWidth: 200 
       preferredWidth: parent.width*0.3 
       fillWidth:true; fillHeight:true 
      } 
     } 
    } 

    footer: Inspector { 
     id: footer 
     height:100 
    } 
} 

答えて

1

grouped propertiesために働く-syntax foo { bar: 1; baz: 2 }Foo { }はQML型Fooのインスタンスを作成するために予約されているが。 attached propertiesの場合は、Foo.bar: 1 -syntaxを使用する必要があります。

Layoutは作成可能なタイプではなく、添付のプロパティのみを提供します。したがって、Foo.bar: 1 -syntaxを使用する必要があります。

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

ApplicationWindow { 
    id: window 
    title: "RB3Jay" 
    width:1280; height:960 
    minimumWidth:600; minimumHeight:300 
    visible: true 

    Rectangle { 
     id: pseudocontent 
     height: parent.height - (header.height + footer.height) 
     color:'orange' 
     anchors { 
      top:header.bottom 
      bottom:footer.top 
      left:parent.left 
      right:parent.right 
     } 
    } 

    header: RowLayout { 
     id: header 
     spacing: 0 
     height: 100 
     width: parent.width 
     Rectangle { 
      color:'red' 
      Layout.minimumWidth:200 
      Layout.maximumWidth:200 
      Layout.preferredWidth:200 
      Layout.fillHeight:true 
     } 
     Rectangle { 
      color:'green' 
      Layout.minimumWidth: 200 
      Layout.preferredWidth: parent.width*0.7 
      Layout.fillWidth:true; Layout.fillHeight:true 
     } 
     Rectangle { 
      color:'blue' 
      Layout.minimumWidth: 200 
      Layout.preferredWidth: parent.width*0.3 
      Layout.fillWidth:true; Layout.fillHeight:true 
     } 
    } 

    footer: Inspector { 
     id: footer 
     height:100 
    } 
} 
+0

ワウ。私は 'Layout.minimumWidth'が同じエラーを投げていることを確信していましたが、私は間違っていたはずです。私の質問は無効です。ご協力ありがとうございました。 – Phrogz

関連する問題