Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 未显示滚动视图中矩形的颜色_Qt_Qml_Qtquick2 - Fatal编程技术网

Qt 未显示滚动视图中矩形的颜色

Qt 未显示滚动视图中矩形的颜色,qt,qml,qtquick2,Qt,Qml,Qtquick2,我想知道为什么我的内部矩形的颜色没有显示出来,而文本的文本却显示出来了。我是否必须使我的矩形成为一个Flickable import QtQuick 2.5 import QtQuick.Controls 1.4 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") color: "#00ff00" menuBar: MenuBar { Menu

我想知道为什么我的内部矩形的颜色没有显示出来,而
文本的文本却显示出来了。我是否必须使我的
矩形
成为一个
Flickable

import QtQuick 2.5
import QtQuick.Controls 1.4

ApplicationWindow {
  visible: true
  width: 640
  height: 480
  title: qsTr("Hello World")
  color: "#00ff00"

  menuBar: MenuBar {
    Menu {
      title: qsTr("File")
      MenuItem {
        text: qsTr("&Open")
        onTriggered: console.log("Open action triggered");
      }
      MenuItem {
        text: qsTr("Exit")
        onTriggered: Qt.quit();
      }
    }
  }

  Rectangle {
    id: motherOfGod
    color: "#554455"

    width: 400
    height: 400

    anchors.centerIn: parent

    TabView {
      anchors.fill: parent

      Tab {
        title: "Red"
        ScrollView {
          Rectangle {
            color: "red"
            height: 1200
            anchors {
              top: parent.top
              left: parent.left
              right: parent.right
            }

            Text { text: "I'm in the red tab" }
          }
        }
      }
      Tab {
        title: "Green"
        Rectangle { color: "green" }
      }
      Tab {
        title: "Blue"
        Rectangle { color: "blue" }
      }
    }
  }
}
尝试:

ScrollView {
  Rectangle {
    color: "red"
    height: 1200
    width: viewport.width
    Text { text: "I'm in the red tab" }
  }
}