2014-02-14 125 views
1

我沒有找到任何好的資源如何使用這個組件,它仍然失敗了我的應用程序的佈局(檢查正確的屬性檢查器)。我做錯了什麼?Qt快速控制ScrollView

沒有滾動型

without ScrollView

與滾動型 with ScrollView

滾動代碼下來請滾動視圖定義最後

import QtQuick 2.1 
import QtQuick.Controls 1.0 
import QtQuick.Layouts 1.1 

ApplicationWindow { 
    title: qsTr("Hello World") 
    width: 1400 
    height: 800 
    color: "#414141" 

    menuBar: MenuBar { 
     Menu { 
      title: qsTr("File") 
      MenuItem { 
       text: qsTr("Exit") 
       onTriggered: Qt.quit(); 
      } 
     } 
    } 

    ColumnLayout { 

     anchors.fill: parent 

     Rectangle { 
      color: "#414141" 
      Layout.fillWidth: true 
      Layout.preferredHeight: 50 
      MyLabel { 
       text: "Toolbar" 
      } 
     } 

     SplitView { 

      Layout.fillHeight: true 
      Layout.fillWidth: true 
      orientation: Qt.Horizontal 
      handleDelegate: MyVSlider {} 

      SplitView { 

       Layout.fillHeight: true 
       Layout.fillWidth: true 
       orientation: Qt.Vertical 
       handleDelegate: MyHSlider {} 

       SplitView { 
        handleDelegate: MyVSlider {} 
        Layout.fillHeight: true 
        Layout.fillWidth: true 
        orientation: Qt.Horizontal 

        Rectangle { 
         color: "#565656" 
         Layout.fillHeight: true 
         Layout.preferredWidth: 200 
         Layout.minimumWidth: 200 
         MyLabel { 
          text: "Tree view" 
         } 
        } 

        Rectangle { 
         color: "#565656" 
         Layout.fillHeight: true 
         Layout.fillWidth: true 
         Layout.minimumWidth: 500 
         Layout.preferredHeight: 300 
         MyLabel { 
          text: "Scene view" 
         } 
        } 
       } 

       Rectangle { 
        color: "#565656" 
        Layout.fillWidth: true 
        Layout.preferredHeight: 200 
        Layout.minimumHeight: 200 
        MyLabel { 
         text: "Console output" 
        } 
       } 
      } 

      Rectangle { 
       id: inspector 
       color: "#565656" 
       Layout.fillHeight: true 
       Layout.preferredWidth: 200 
       Layout.minimumWidth: 200 
       MyLabel { 
        text: "Properties inspector" 
       } 
      } 


      ScrollView { 
       contentItem: inspector 
      } 

     } 
    } 

} 

回答

0

你是否試圖讓你的inspector元素可以滾動?您需要將元素滾動到ScrollView之內。

ScrollView { 
    Rectangle { 
      id: inspector 
      color: "#565656" 
      Layout.fillHeight: true 
      Layout.preferredWidth: 200 
      Layout.minimumWidth: 200 
      MyLabel { 
       text: "Properties inspector" 
      } 

      // Make the thing really big. 
      width: 1000 
      height: 1000 
    } 
} 

這將導致你的inspector帶有滾動條顯示出來,如果你設置widthheight正如我上面一樣。